成人AV在线无码|婷婷五月激情色,|伊人加勒比二三四区|国产一区激情都市|亚洲AV无码电影|日av韩av无码|天堂在线亚洲Av|无码一区二区影院|成人无码毛片AV|超碰在线看中文字幕

優(yōu)化Excel數(shù)據(jù)整理:實現(xiàn)分散數(shù)據(jù)單元格列向左移合并

修法布施得聰明智慧,多分享讓生活更美好。上回分享了《Excel怎樣快速根據(jù)重復字段合并其它列數(shù)據(jù)》,介紹了行相同數(shù)據(jù)其不同數(shù)據(jù)合并至一行中處理方法。今天我們將探討如何利用Excel將分散的數(shù)據(jù)單元格列

修法布施得聰明智慧,多分享讓生活更美好。上回分享了《Excel怎樣快速根據(jù)重復字段合并其它列數(shù)據(jù)》,介紹了行相同數(shù)據(jù)其不同數(shù)據(jù)合并至一行中處理方法。今天我們將探討如何利用Excel將分散的數(shù)據(jù)單元格列條向左移到一起,以提高數(shù)據(jù)整理效率。

步驟1:準備工作

首先打開Microsoft Office Excel,新建文檔并保存文件名為《Excel如何把分散的數(shù)據(jù)單元格列條向左移到一起.xlsm》。接著按下快捷鍵ALT F11打開VBE(宏)編輯界面,在菜單欄【插入】下拉列表中選擇【模塊(M)】。

步驟2:插入宏代碼

在新插入的模塊1中,復制粘貼以下代碼:

```vba

Option Base 1

Sub 數(shù)據(jù)向左移動()

Dim myr As Range, i As Long, j As Long, r As Long, c As Long

Dim k As Long, n As Long, x As Long, mb, m

Set myr Selection

m

r

c

k 0: n 0: x 0

ReDim mb(r, 2)

For i 2 To c

For j 1 To r

If j 1 Then

If myr.Cells(j, i).Value <> "" Then

x x 1

mb(x, 1) j

k 1

Else

n 1

End If

Else

If myr.Cells(j, i).Value <> "" Then

k k 1

If k 1 Then

x x 1

mb(x, 1) j

k 1

n 0

Else

n 1

End If

Else

n n 1

End If

End If

If j r And myr.Cells(j, i).Value <> "" Then

mb(x, 2) j

End If

Next j

For j 1 To x

If mb(j, 1) mb(j, 2) Then

If myr.Cells(mb(j, 1), i - 1).Value "" Then

myr.Cells(mb(j, 1), i).Cut Destination:myr.Cells(mb(j, 1), i - 1)

Else

n 0

End If

Else

For k mb(j, 1) To mb(j, 2)

If myr.Cells(k, i - 1).Value <> "" Then

n 1

Exit For

End If

Next k

If n 0 Then

For k mb(j, 1) To mb(j, 2)

myr.Cells(k, i).Cut Destination:myr.Cells(k, i - 1)

Next k

End If

End If

Next j

Next i

Set myr Range(m)

k 0: n 0: x 0

Erase mb

ReDim mb(r, 2)

End Sub

```

步驟3:應用宏代碼

回到工作表窗口,選中原數(shù)據(jù)表,運行【數(shù)據(jù)向左移動】宏。在菜單欄中選擇【視圖】,再從下拉列表中選擇【宏】,打開宏對話框,選擇該宏名稱,執(zhí)行。這將使右邊的數(shù)據(jù)單元格向左移動,有些數(shù)據(jù)可能需要多次運行才能得到最終結果。

結語

如果這篇經驗對您有所幫助,請點擊“投票點贊”或者“收藏”以支持我!若仍有疑問,請隨時點擊“我有疑問”。感謝閱讀!

標簽: