|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 拆分()
Dim ar As Variant
Dim br()
With Sheets("sheet1")
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 3 Then MsgBox "数据源我!": End
ar = .Range("a1:c" & r)
End With
ReDim br(1 To 50000, 1 To 3)
For i = 3 To UBound(ar)
If ar(i, 3) <> "" Then
rr = Split(ar(i, 3), Chr(10))
For s = 0 To UBound(rr)
If rr(s) <> "" Then
n = n + 1
br(n, 1) = n
br(n, 2) = ar(i, 2)
br(n, 3) = rr(s)
End If
Next s
End If
Next i
With Sheet2
rs = .Cells(Rows.Count, 1).End(xlUp).Row
If rs > 2 Then .Range("a3:c" & rs) = Empty
.[a3].Resize(n, 3) = br
End With
MsgBox "ok!"
End Sub
|
|