ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Does the sheet exist? (https://www.excelbanter.com/excel-programming/307960-does-sheet-exist.html)

Dr.Schwartz

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

Is anybody game?
The Doctor

RB Smissaert

Does the sheet exist?
 
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

"Dr.Schwartz" wrote in message
...
I need the syntax for checking that a given sheet exist identified by it's
CODE name.

Is anybody game?
The Doctor




All times are GMT +1. The time now is 03:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com