Does the sheet exist?

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

Guest

I need the syntax for checking that a given sheet exist identified by it's
CODE name.

Is anybody game?
The Doctor
 
Something like this will do it:

Function TestForSheet(lSheetNumber As Long) As Boolean

Dim strSheetName As String

On Error Resume Next
strSheetName = Sheets(lSheetNumber).Name

If Err.Number = 0 Then
TestForSheet = True
Else
TestForSheet = False
End If

On Error GoTo 0

End Function


Sub test()
MsgBox TestForSheet(100)
End Sub


RBS
 

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

Back
Top