|
Sub 一列6行参考()
Dim sht As Worksheet, n As Integer, iFlag As Boolean
Dim ShtName() As String
Application.DisplayAlerts = False
For Each sht In Sheets
If sht.Name <> "数据" And sht.Name <> "模板" And sht.Name <> "最后效果" Then sht.Delete
Next
Application.DisplayAlerts = True
Set d = CreateObject("scripting.dictionary")
arr = Sheet1.UsedRange
For i = 4 To UBound(arr)
zu = arr(i, 11)
If zu <> "" Then d(zu) = d(zu) & "," & i
Next
Application.ScreenUpdating = False
rmax = 6
For Each zu In d.keys
m = m + 1
xrr = Split(d(zu), ",")
rs = UBound(xrr)
If rs Mod 6 = 0 Then
n = (rs - 0.1) \ rmax
Else
n = (rs - 0.1) \ rmax + 1
End If
For pg = 1 To n
Sheets("模板").Copy after:=Sheets(Sheets.Count)
With ActiveSheet
.Name = zu & "-" & pg
ReDim brr(1 To rmax, 1 To UBound(arr, 2))
s = (pg - 1) * 6
For r = 1 To rmax
If r + s <= rs Then
i = xrr(r + s)
brr(r, 1) = arr(i, 3)
brr(r, 9) = arr(i, 11)
brr(r, 11) = arr(i, 12)
End If
Next
.[C5].Resize(6, 11) = brr
End With
Next
Next
Sheets("数据").Activate
Application.ScreenUpdating = True
End Sub |
|