|
- Sub test()
- Dim r&, i&
- Dim arr, brr
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:b" & r)
- ReDim brr(1 To UBound(arr), 1 To 51)
- xm = ""
- m = 0
- For i = 1 To UBound(arr)
- If arr(i, 1) <> xm Then
- m = m + 1
- brr(m, 1) = arr(i, 1)
- brr(m, 2) = arr(i, 2)
- xm = arr(i, 1)
- n = 2
- Else
- n = n + 1
- If n > 51 Then
- m = m + 1
- brr(m, 1) = arr(i, 1)
- brr(m, 2) = arr(i, 2)
- n = 2
- Else
- brr(m, n) = arr(i, 2)
- End If
- End If
- Next
- End With
- With Worksheets("sheet4")
- .UsedRange.Offset(1, 0).Clear
- .Range("a2").Resize(m, UBound(brr, 2)) = brr
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|