|
参与一下。。。- Sub ykcbf() '//2024.1.19
- Set d = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim tm: tm = Timer
- p = ThisWorkbook.Path & ""
- Set sh = ThisWorkbook.Sheets("数据")
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- sht.Delete
- End If
- Next
- arr = sh.UsedRange
- For i = 2 To UBound(arr)
- If arr(i, 9) <> Empty Then
- s = Format(arr(i, 9), "yyyy-m-d")
- If Not d.Exists(s) Then
- Set d(s) = CreateObject("scripting.dictionary")
- End If
- d(s)(i) = i
- End If
- Next i
- For Each k In d.keys
- sh.Copy after:=Sheets(Sheets.Count)
- Set sht = Sheets(Sheets.Count)
- m = 0
- ReDim brr(1 To d(k).Count, 1 To 10)
- With sht
- .DrawingObjects.Delete
- .UsedRange.Offset(d(k).Count + 2).Clear
- .Name = k
- For Each kk In d(k).keys
- m = m + 1
- brr(m, 1) = m
- For j = 2 To UBound(arr, 2)
- brr(m, j) = arr(kk, j)
- Next
- Next
- .[a2].Resize(m, 9) = brr
- r = .Cells(Rows.Count, 1).End(3).Row
- .Cells(r + 1, 1).Resize(1, 9) = ""
- .Cells(r + 1, 2) = "合计"
- .Cells(r + 1, 7).FormulaR1C1 = "=SUM(R2C:R" & "[-1]C)"
- .Cells(r + 2, 2) = "验收人:"
- .Cells(r + 2, 7) = "送货人:"
- .Range(.Cells(r + 1, 1), .Cells(r + 2, 9)).Interior.ColorIndex = 6
- End With
- Next k
- sh.Activate
- Set d = Nothing
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
|