|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- With Worksheets("sheet2")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a1:i" & r)
- ReDim brr(1 To UBound(arr) * 20, 1 To UBound(arr, 2))
- m = 0
- For i = 1 To UBound(arr)
- xm = Split(arr(i, 2), "、")
- For j = 0 To UBound(xm)
- m = m + 1
- brr(m, 1) = arr(i, 1)
- brr(m, 2) = xm(j)
- For k = 3 To UBound(arr, 2)
- brr(m, k) = arr(i, k)
- Next
- Next
- Next
- End With
- With Worksheets("sheet1")
- .Range("a1").Resize(UBound(brr), UBound(brr, 2)) = brr
- For i = UBound(brr) To 2 Step -1
- If brr(i - 1, 1) = brr(i, 1) Then
- .Cells(i - 1, 1).Resize(2, 1).Merge
- End If
- Next
- End With
- End Sub
复制代码 |
|