|
参与一下。。。- Sub ykcbf() '//2024.1.18
- Dim d, i%, arr, sh As Worksheet, sht As Worksheet, k, kk
- Set d = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim tm: tm = Timer
- Set sh = ThisWorkbook.Sheets("格式模板")
- arr = Sheets("内容数据").UsedRange
- For i = 2 To UBound(arr)
- s = arr(i, 4)
- If arr(i, 1) <> Empty Then
- 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
- fn = Format(k, "yyyy-m-d")
- sh.Copy
- Set wb = ActiveWorkbook
- m = 0
- ReDim brr(1 To d(k).Count, 1 To 6)
- With wb.Sheets(1)
- .Name = fn
- .[b1] = k
- For Each kk In d(k).keys
- m = m + 1
- For j = 1 To 3
- brr(m, j) = arr(kk, j)
- Next
- For j = 4 To 6
- brr(m, j) = arr(kk, j + 1)
- Next
- Next
- .Columns(4).NumberFormatLocal = "0"
- With .[a3].Resize(m, 6)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- wb.SaveAs p & fn
- wb.Close 1
- End With
- Next k
- Sheets("内容数据").Activate
- Set d = Nothing
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
|