|
参与一下。。。
- Sub ykcbf() '//2024.11.27
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("销售单模板")
- Dim tm: tm = Timer
- With Sheets("源数据")
- r = .Cells(Rows.Count, 4).End(3).Row
- arr = .[a1].Resize(r, 9)
- rq = CDate(arr(2, 1))
- End With
- For i = 2 To UBound(arr)
- If arr(i, 2) <> Empty Then s = arr(i, 2) & "|" & arr(i, 3)
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(i) = i
- Next
- sh.Copy
- Set wb = ActiveWorkbook
- With wb.Sheets(1)
- .Name = Format(rq, "yyyy-m-d")
- For Each k In d.keys
- n = n + 1
- r = 17 * (n - 1) + 1
- sh.Rows("1:17").Copy .Cells(r, 1)
- b = Split(k, "|")
- .Cells(r + 1, 5) = "日 期:" & rq & " 送货时段:"
- .Cells(r + 2, 6) = b(0)
- .Cells(r + 1, 2) = b(1)
- m = 3
- For Each kk In d(k).keys
- m = m + 1
- For j = 4 To 8
- .Cells(r + m, j - 2) = arr(kk, j)
- Next
- Next
- Next
- End With
- wb.SaveAs p & "销售单" & Format(rq, "yyyy-m-d")
- wb.Close
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|