Worksheet exists

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there an easy way to find out if a sheet with a particular name already
exists in a workbook?

Thanks, Kaval
 
One way:

Const sNAME As String = "ParticularName"
Dim ws As Worksheet
On Error Resume Next
Set ws = Worksheets(sNAME)
On Error GoTo 0
If Not ws Is Nothing Then
MsgBox "Worksheet " & sNAME & " exists"
Else
MsgBox "Worksheet " & sNAME & " doesn't exist"
End If
 
On Error Resume Next
Sheets("MySheet").Select
If Err Then
MsgBox "MySheet does not exist"
End If
On Error GoTo 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Does a worksheet exist 3
Excel VBA 0
Cell lies within range 3
Suspend Execution 1
Cell Precedents 2
Cell Types 2
Windows Zoom 1
Paste Array into worksheet 1

Back
Top