|
本帖最后由 ykcbf1100 于 2024-3-29 20:15 编辑
参与一下。。。
- Sub ykcbf() '//2024.3.29
- Dim arr, brr, d
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- Set sh = ThisWorkbook.Sheets("委托")
- xm = sh.[f4].Value
- arr = Sheets("数据库").Range("a1").CurrentRegion
- b = [{4,4,5,10,9,8,11}]
- r1 = 10 '//起始行号
- p = 11 '//间隔行数
- For Each sht In Sheets
- If sht.Name <> sh.Name And sht.Name <> "数据库" Then
- sht.Delete
- End If
- Next
- For i = 2 To UBound(arr)
- s = arr(i, 22)
- If Not d.exists(s) Then
- Set d(s) = CreateObject("Scripting.Dictionary")
- End If
- d(s)(i) = i
- Next
- m = d(xm).Count
- ReDim brr(1 To m, 1 To 7)
- For Each kk In d(xm).keys
- n = n + 1
- For j = 1 To UBound(b)
- brr(n, j) = arr(kk, b(j))
- Next
- Next
- On Error Resume Next
- For i = 1 To m Step p
- x = x + 1
- ReDim zrr(1 To p, 1 To 7)
- For k = 1 To p
- For j = 1 To 7
- zrr(k, j) = brr(i + (k - 1), j)
- Next
- Next
- sh.Copy after:=Sheets(Sheets.Count)
- Set sht = ActiveSheet
- With sht
- .Name = xm & IIf(m <= p, "", "(" & x & ")")
- .DrawingObjects.Delete
- .Cells(r1, 2).Resize(p, 7) = zrr
- If m < p Then .Cells(r1 + n, 2) = "以下空白"
- End With
- Next i
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|