|
附件已不同,改一下吧。
- Sub ykcbf() '//2024.8.23 总表拆分
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim tm: tm = Timer
- Dim currentDate As String
- currentDate = Format(Date, "yyyy-mm-dd")
- Set d = CreateObject("scripting.dictionary")
- Set fso = CreateObject("Scripting.FileSystemObject")
- p = ThisWorkbook.Path & ""
- Set sh = ThisWorkbook.Sheets("清单")
- col = 13 '//拆分列号
- With sh
- r = .Cells(Rows.Count, col).End(xlUp).Row
- c = .Cells(1, "XFD").End(1).Column
- arr = .[a1].Resize(r, c)
- End With
- For i = 3 To UBound(arr)
- s = arr(i, col)
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(i) = i
- Next
- On Error Resume Next
- fn = "询价单-"
- b = [{1,2,3,4,5,6,7,8,9,10,11,12,14,15,17,18,99,99,24}]
- For Each k In d.keys
- m = 0
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- Sheets("询价单").Copy
- Set wb = ActiveWorkbook
- With wb.Sheets(1)
- .[p2] = CDate(Date)
- .DrawingObjects.Delete
- For Each kk In d(k).keys
- m = m + 1
- brr(m, 1) = m
- For j = 2 To UBound(b)
- brr(m, j) = arr(kk, b(j))
- Next
- Next
- If m > 6 Then
- For i = 1 To m - 6
- Cells(5 + i, 1).EntireRow.Insert
- Next i
- End If
- .[a4].Resize(m, 19) = brr
- r1 = IIf(m <= 6, 10, 4 + m)
- End With
- wb.SaveAs p & currentDate & fn & k
- wb.Close
- Next
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "拆分完毕,共用时: " & Format(Timer - tm, "0.000秒"), , "提示"
- End Sub
复制代码
|
|