|
Sub 新建()
Application.ScreenUpdating = False
Dim ar As Variant
Dim i As Long, rs As Long
Dim d As Object '
Set d = CreateObject("scripting.dictionary")
For Each sh In Sheets '
If sh.Index > 3 Then
d(sh.Name) = ""
End If
Next sh
With Sheets("基本数据")
rs = .Cells(Rows.Count, 1).End(xlUp).Row
If rs < 3 Then MsgBox "基本数据为空!": End
ar = .Range("a2:c" & rs) '
End With ''
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
mc = Trim(ar(i, 3))
If Not d.exists(mc) Then
m = m + 1 ''
Sheets("样表").Copy after:=Sheets(Sheets.Count) '
With ActiveSheet
.Name = mc ''
.[c1] = ar(i, 1)
.[d1] = ar(i, 2)
.[e1] = ar(i, 3)
End With
End If
End If
Next i
Set d = Nothing
If m = "" Then
ts = "本次没有创建工作表!"
Else
ts = "本次创建了" & m & "个工作表!"
End If ''
Application.ScreenUpdating = True
MsgBox ts
End Sub
|
评分
-
2
查看全部评分
-
|