我正在尝试在检查列和其他内容之前验证第一张表的名称,但我无法使其工作。这是我到目前为止所尝试的。谢谢你的帮助。
SFile = Worksheets("Macro").Range("F17").Value
Set oWB = Application.Workbooks.Open(SFile)
Dim sh As Worksheet, flg As Boolean
Set sh = oWB.Worksheets("SheetName")
If sh.Name Like "SheetName" Then flg = True:
If flg = True Then
MsgBox "Sheet Name Exist"
Else
MsgBox "Sheet name does not exist"
oWB.Close False
Exit Sub
End If
答案 0 :(得分:0)
好的,我得到了它。
For i = 1 To Worksheets.Count
If Worksheets(i).Name = "SheetName" Then
exists = True
End If
Next i
If Not exists Then
MsgBox "Please select the correct File"
bZX.Close False
Exit Sub
End If