A B C
1 data1 name1,name2 data2
2 data3 name3,name4,name5 data4
变成
A B C
1 data1 name1 data2
2 data1 name2 data2
3 data3 name3 data4
4 data3 name4 data4
5 data3 name5 data4
name之间的分隔就是逗号
用 VBA 可以做,而且很简单。
原始数据中那一列是A列?
sheet1放原始数据,sheet2代码:
VB code
Private Sub Worksheet_Activate()
Dim i As Integer, l As Integer, s
l = 1
With Sheet1
For i = 1 To .[A65530].End(xlUp).Row
For Each s In Split(.Range("B" & i), ",")
Range("A" & l & ":C" & l) = Array(.Range("A" & i), s, .Range("C" & i))
l = l + 1
Next s
Next i
End With
End Sub