|
楼主 |
发表于 2024-11-29 16:03
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 新建工作表()
Application.ScreenUpdating = False
Dim ar As Variant
Dim i As Long, r As Long, rs As Long
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("单元号")
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "单元号工作表为空,请先导入数据!": End
ar = .Range("a1:c" & r)
End With
For Each sh In Sheets
If sh.Index > 2 Then
d(sh.Name) = ""
End If
Next sh
For i = 2 To UBound(ar)
If ar(i, 1) <> "" And ar(i, 2) <> "" Then
s = ar(i, 1) & "|" & ar(i, 2)
If Not d.exists(s) Then
Sheets("模板").Copy after:=Sheets(Sheets.Count)
With ActiveSheet
.Name = s
.[z4] = ar(i, 1)
.[f7] = ar(i, 2)
.[u5] = ar(i, 3)
End With
End If
End If
Next i
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
谢谢大神 |
|