Hi,
I want to determine if a worksheet named Sheets("Chart") exists. How
can I do this using VBA?
Thank you,
Robert Stober
An alternate way which does not "abuse" the error mechanism:
(function header shamelessly stolen from V. Nanavati)
Function WorksheetExists(wsName As String, _
Optional wbName As String) As Boolean
If wbName = "" Then wbName = _
ActiveWorkbook.Name
Dim x as Variant
WorksheetExists = false
For Each x In Workbooks(wbName).Worksheets
If x.Name = wsName Then
WorksheetExists = True
Exit Function
Next
End Function
(I know it's silly to call it abuse, but I always get caught by
forgetting to do On Error Goto 0, so I tend to avoid using it as an
exception mechanism)