Friday, December 27, 2013

VBA - Determine if worksheet of a given name exists

The following function takes a worksheet name as input and returns True/False whether or not a worksheet of that name exists:


Public Function WorksheetExists(ByVal WorksheetName As String) As Boolean

    On Error Resume Next
        WorksheetExists = (Sheets(WorksheetName).Name <> "")
    On Error GoTo 0

End Function

No comments:

Post a Comment