Created
July 12, 2014 22:05
-
-
Save danwagnerco/bdb62ea31f45033fc004 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | |
'INPUT : SheetName, the name (string) of the sheet we're looking for | |
'OUTPUT : True or false (sheet was found, sheet was not found) | |
'SPECIAL CASE : none | |
'EXAMPLES BELOW: | |
' | |
'assume that a sheet named "YaGotMe" exists | |
'DoesSheetExist("YaGotMe") | |
'>> True | |
' | |
'assume that a sheet named "NotHere" does NOT exist | |
'DoesSheetEixst("NotHere") | |
'>> False | |
' | |
Public Function DoesSheetExist(SheetName As String) As Boolean | |
Dim Obj As Object | |
On Error Resume Next | |
Set Obj = ThisWorkbook.Worksheets(SheetName) | |
If Err = 0 Then | |
DoesSheetExist = True | |
Else | |
DoesSheetExist = False | |
End If | |
On Error GoTo 0 | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment