Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA - does a worksheet exist

Status
Not open for further replies.

Skob

Technical User
Jul 4, 2003
6
GB
I'm trying to write some code that determines whether a worksheet exists and directs the user to different user forms depending on whether it does or it doesn't. The trouble is I can't seem to find a way of checking the existence of a sheet in a workbook. HELP!

The code I am using is something like

Code:
Private Sub WorkSheetCheck()

If IsObject(Sheets("DataEntrySheet")  Then
    ReminderForm.Show
Else
    DataEntryForm.Show
End If

End Sub

The IsObject doesn't work, along with many other variations I have tried.

I'm sure someone must have done this before ...

Andy



 
Hi
Another way of seeing if a sheet exists

Code:
On Error Resume Next
Worksheets("NoSuchSheet").Activate
If Err.Number <> 0 Then MsgBox &quot;sheet doesn't exist!&quot;
On Error GoTo 0

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top