If Worksheet exists...Then run code
try this:
Function bSheetExists(wksName As String) As Boolean
' Checks if a specified worksheet exists.
'
' Arguments: wksName The name of the worksheet
'
' Returns: TRUE if the sheet exists
Dim x As Worksheet
On Error Resume Next
Set x = ActiveWorkbook.Sheets(wksName)
bSheetExists = (Err = 0)
End Function
To use:
If bSheetExists("NameOfSheet") Then...
-OR-
If Not bSheetExists("NameOfSheet") Then...
Hope this helps!
GS
|