|
代码:
- Sub test()
- Application.ScreenUpdating = 0
- Set sht = ThisWorkbook.Sheets("资金支付查询20240517124124763")
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- arr = sht.UsedRange
- For i = 4 To UBound(arr)
- If arr(i, 25) <> "" Then d(arr(i, 25)) = ""
- Next
- For Each Key In d.keys
- ReDim brr(1 To 10000, 1 To 3)
- n = 1
- brr(n, 1) = arr(2, 25)
- brr(n, 2) = arr(2, 32)
- brr(n, 3) = arr(2, 9)
- For i = 4 To UBound(arr)
- ss = arr(i, 25)
- If Key = ss And ss <> "" Then
- s = arr(i, 25) & arr(i, 32)
- If Not d1.exists(s) Then
- n = n + 1
- d1(s) = n
- brr(n, 1) = arr(i, 25)
- brr(n, 2) = arr(i, 32)
- brr(n, 3) = arr(i, 9)
- Else
- m = d1(s)
- brr(m, 3) = brr(m, 3) + arr(i, 9)
- End If
- End If
- Next
- With ThisWorkbook.Sheets.Add(after:=ThisWorkbook.Sheets(Sheets.Count))
- s = Key & " " & Format(Now, "dd日 hh时mm分")
- If Len(s) > 31 Then Key = Left(s, 20): s = Key & " " & Format(Now, "dd日 hh时mm分")
- .Name = s
- .[a1].Resize(n, 3) = brr
- .UsedRange.HorizontalAlignment = xlCenter
- .UsedRange.Borders.LineStyle = 1
- .UsedRange.Columns.AutoFit
- End With
- d1.RemoveAll
- Next
- Set d = Nothing
- Set d1 = Nothing
- Beep
- Application.ScreenUpdating = 1
- End Sub
复制代码 |
|