WorksheetExists

S

Steve

My compiler doesn't recognize WorksheetExists(sheet,book). Is there a
setting in references I need to set?
 
G

Gary''s Student

Download from Pearson's site or:

Function WorksheetExists(SheetName As Variant, _
Optional WhichBook As Workbook) As Boolean
'from Chip Pearson
Dim WB As Workbook
Set WB = IIf(WhichBook Is Nothing, ThisWorkbook, WhichBook)
On Error Resume Next
WorksheetExists = CBool(Len(WB.Worksheets(SheetName).Name) > 0)
End Function
 
Top