|
Sub 拆分为工作簿()
Application.ScreenUpdating = False
Dim ar As Variant
Dim i As Long, r As Long, rs As Long
Dim br()
ar = Sheets("信息汇总表").[a1].CurrentRegion
For i = 5 To UBound(ar)
n = 0
ReDim br(1 To UBound(ar, 2), 1 To 9)
If Trim(ar(i, 3)) <> "" Then
For j = 9 To UBound(ar, 2) Step 9
m = 0
If Trim(ar(i, j)) <> "" Then
n = n + 1
For s = j To j + 8
m = m + 1
br(n, m) = ar(i, s)
Next s
End If
Next j
Sheets("模板").Copy
Set wb = ActiveWorkbook
With wb.Worksheets(1)
.Name = ar(i, 3)
.[b2] = ar(i, 1)
.[d2] = ar(i, 3)
.[f2] = ar(i, 4)
.[h2] = ar(i, 5)
.[j2] = ar(i, 6)
.[l2] = ar(i, 7)
.[n2] = ar(i, 8)
.[b5].Resize(n, UBound(br, 2)) = br
End With
wb.SaveAs Filename:=ThisWorkbook.Path & "\" & ar(i, 1) & "_" & ar(i, 3)
wb.Close
End If
Next i
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|