完整的解决方案
Sub newmac()
Dim rowCount As Long
Dim rowOffset As Long
Dim rowCurrent As Long
Dim subRow As Long
Dim c() As String
rowOffset = 0
rowCount = Application.ActiveSheet.UsedRange.Rows.CountLarge
For i = 1 To rowCount
rowCurrent = i + rowOffset
c = Split(Cells(rowCurrent, 4), ",")
If (UBound(c) <= 0) Then c = Split(Cells(rowCurrent, 4), " ")
If (UBound(c) <= 0) Then c = Split(Cells(rowCurrent, 4), "-")
' more than 1 item. process
If (UBound(c) > 0) Then
Cells(rowCurrent, 4) = c(0)
For j = 1 To UBound(c)
subRow = rowCurrent + j
range("A" & rowCurrent & ":D" & rowCurrent).Copy
range("A" & subRow & ":D" & subRow).Insert
Cells(subRow, 4) = c(j)
Next j
rowOffset = rowOffset + UBound(c)
End If
Next i
End Sub
我的结果:
a b c 1
a b c 2
a b c 3
a b c 4
a b c 5
a b c 6
a d e 1
a d e 3
a d e 5
a f g 7
a f g 8