VB自动生成31个工作表,如何编写代码?
发布网友
发布时间:2022-06-14 12:53
我来回答
共1个回答
热心网友
时间:2023-10-18 22:48
Sub ZjGzb()
Dim She As Worksheet
Dim Zfc As String
Dim i As Integer
For i = 1 To 31
Zfc = "表" & LTrim(i)
If Not GzbSfCz(Zfc) Then
Set She = Sheets.Add(after:=Sheets(Sheets.Count))
She.Name = Zfc
End If
Next
End Sub
Public Function GzbSfCz(ByVal Xstr) As Boolean
Dim Shee As Worksheet
Dim Fhz As Boolean
Fhz = False
For Each Shee In Sheets
If Shee.Name = Xstr Then
Fhz = True
Exit For
End If
Next