|
参与一下。。。- Sub ykcbf() '//2024.1.29
- Dim arr, brr, d
- Set d = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim tm: tm = Timer
- Set sh = Sheets("明细表")
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- sht.Delete
- End If
- Next
- arr = sh.UsedRange
- For i = 3 To UBound(arr)
- s = arr(i, 3)
- If Not d.Exists(s) Then
- Set d(s) = CreateObject("scripting.dictionary")
- End If
- d(s)(i) = i
- Next i
- For Each k In d.keys
- m = 0
- ReDim brr(1 To d(k).Count, 1 To 4)
- sh.Copy after:=Sheets(Sheets.Count)
- Set sht = Sheets(Sheets.Count)
- With sht
- .Name = k
- .DrawingObjects.Delete
- For Each kk In d(k).keys
- m = m + 1
- brr(m, 1) = m
- For j = 2 To 4
- brr(m, j) = arr(kk, j)
- Next
- Next
- .Range("A5").Resize(m, 4) = brr
- .UsedRange.Offset(m + 2).Clear
- End With
- Next k
- sh.Activate
- Set d = Nothing
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
|