我有具有在Excel以下數據:Excel宏 - 逗號分隔細胞對行
a, b, c
d
e
f, g
h
i
,每行代表一個行和在一個小區中。
我想將其轉換爲:
a
b
c
d
e
f
g
h
i
我使用下面的宏,但我不能讓自動調整大小做插入,而不是覆蓋單元格值。任何幫助表示讚賞。
Sub SplitCells()
Dim i As Long
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
For i = 1 To Selection.Rows.Count
Dim splitValues As Variant
splitValues = split(Selection.Rows(i).Value, ",")
Selection.Rows(i).Resize(UBound(splitValues) - LBound(splitValues) + 1).Value = Application.Transpose(splitValues)
Next i
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
很好用,謝謝 – 2009-01-23 15:22:24