Skip to content

Instantly share code, notes, and snippets.

@mrowles
Last active December 16, 2015 07:39
Show Gist options
  • Save mrowles/5400681 to your computer and use it in GitHub Desktop.
Save mrowles/5400681 to your computer and use it in GitHub Desktop.
Microsoft Excel: This function checks if a Worksheet exists by accepting a Worksheet name as a parameter and looping through available worksheets. It will return false if the name is not found, otherwise it will return true if a Worksheet with the passed parameter exists. It is case-insensitive.
Function WorksheetExists(wsName As String) As Boolean
Dim ws As Worksheet
Dim found As Boolean
found = False
wsName = UCase(wsName)
For Each ws In ThisWorkbook.Sheets
If UCase(ws.Name) = wsName Then
found = True
Exit For
End If
Next
WorksheetExists = found
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment