|
Sub test()
Application.ScreenUpdating = False
Dim ar As Variant
Dim i As Integer
With Sheets("数据源")
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a1:g" & r)
End With
Application.DisplayAlerts = False
For Each sh In Sheets
If sh.Index > 2 Then
sh.Delete
End If
Next sh
Application.DisplayAlerts = True
For i = 2 To UBound(ar)
If Trim(ar(i, 2)) <> "" Then
Sheets("模板").Copy after:=Sheets(Sheets.Count)
With Sheets(Sheets.Count)
.Name = ar(i, 1) & ar(i, 2)
.[c3] = ar(i, 3)
.[f3] = ar(i, 6)
.[l3] = ar(i, 5)
.[c4] = ar(i, 7)
End With
End If
Next i
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|