|
Sub 批量生成()
Application.ScreenUpdating = False
With Sheets("数据源")
r = .Cells(Rows.Count, 2).End(xlUp).Row
ar = .Range("a1:h" & 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 ActiveSheet
.[a3] = ar(i, 6)
.[b3] = ar(i, 7)
.[g3] = ar(i, 8)
.[a6] = ar(i, 2)
If Trim(ar(i, 8)) = "KAY" Then
.[c6] = "2222222"
.[c7] = "3333333"
.[d6] = 3
.[d7] = 4
ElseIf Right(Trim(ar(i, 8)), 1) = "U" Then
.[c6] = "444444"
.[d6] = 7
Else
.[c6] = "1111111"
.[d6] = 7
End If
.Name = ar(i, 2)
End With
End If
Next i
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|