Excel里面如何如此分割单元格
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之间的分隔就是逗号
[解决办法]
sheet1放原始数据,sheet2代码:
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 WithEnd Sub