|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
生成工作表的代码
Sub chaifen()
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
Set dc = CreateObject("scripting.dictionary")
For Each sh In Sheets
If sh.Index > 2 Then
dc(sh.Name) = ""
End If
Next sh
With Sheets("MAIN")
y = Sheets("MAIN").Cells(3, Columns.Count).End(xlToLeft).Column
ar = .Range(.Cells(3, 2), .Cells(3, y))
For j = 1 To UBound(ar, 2)
If Len(Trim(ar(1, j))) > 0 Then
If Not dc.exists(Trim(ar(1, j))) Then
Sheets("模板").Copy after:=Sheets(Sheets.Count)
With Sheets(Sheets.Count)
.Name = ar(1, j)
.[a1] = ar(1, j)
End With
End If
End If
Next j
End With
MsgBox "ok!"
End Sub
|
|