• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Check if sheet exists vba

Hello Team.

Wanted to check if particular sheet exists before i processed my code as my entire code is based on that sheet..hope it make sense..Sheet may be deleted so.

Cheers!
 
James...You call this way...Change sheet name as per your requirement.

Code:
Sub test()
If Not WorksheetExists("Sheet10") Then
        MsgBox "Sheet not available", vbExclamation, "Error"
        Exit Sub
End If
End Sub
 
That's great.. Perfect

Just help with the below one..not good with vba though.

Code:
Sub test()
If Not WorksheetExists("Sheet10") Then
        MsgBox "Sheet not available", vbExclamation, "Error"
        Exit Sub
else
< Proced with the code>
End If
End Sub
 
Hi !

You can also directly use worksheet function ISREF !
See samples in threads of this forum …
 
That's great.. Perfect

Just help with the below one..not good with vba though.

Code:
Sub test()
If Not WorksheetExists("Sheet10") Then
        MsgBox "Sheet not available", vbExclamation, "Error"
        Exit Sub
else
< Proced with the code>
End If
End Sub

James

Although what you have posted will work, the else is superfluous

Code:
Sub test()
If Not WorksheetExists("Sheet10") Then
        MsgBox "Sheet not available", vbExclamation, "Error"
        Exit Sub
End If

< Proced with the code>

End Sub

will do what you want
 
Back
Top