|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
修改一下。。。- Sub ykcbf() '//2024.12.24
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- arr = Sheets("清单明细").UsedRange
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- On Error Resume Next
- For i = 2 To UBound(arr) Step 2
- s = arr(i, 1) & "|" & arr(i, 2)
- If s <> Empty Then
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = arr(i, 1)
- brr(m, 2) = arr(i, 2)
- End If
- End If
- Next
- Max = m
- For j = 3 To UBound(arr, 2)
- d.RemoveAll
- m = 0
- For i = 2 To UBound(arr) Step 2
- s = arr(i, j)
- If s <> Empty Then
- If Not d.exists(s) Then
- m = m + 2
- d(s) = m
- brr(m - 1, j) = arr(i, j)
- brr(m, j) = arr(i + 1, j)
- Else
- r = d(s)
- brr(r, j) = brr(r, j) + arr(i + 1, j)
- End If
- End If
- Next
- Max = IIf(Max < m, m, Max)
- Next
- With Sheets("统计数量")
- .UsedRange.Offset(1).ClearContents
- .[a3].Resize(Max, UBound(arr, 2)) = brr
- ActiveWindow.DisplayZeros = False
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|