Does the sheet exist?

D

Dr.Schwartz

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

Is anybody game?
The Doctor
 
R

RB Smissaert

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
 
Top