Sub creatsheet()
Dim a, b As String
Dim SH As Worksheet
Dim S As Range
Dim aa As Integer
For Each S In Application.Selection
a = Left(S, 2)
If a = "XT2019" Then
b = Right(S, 3)
For aa = 1 To Sheets.Count
If Sheets(aa).Name = b Then
MsgBox ("这个文档已存在")
GoTo IPTR
End If
Next
Set SH = Worksheets.Add
SH.Name = b
IPTR: Worksheets("SHEET1").Select
End If
Next
End Sub