20 | 09 | 2017

Check if a Sheet Exists

To check if a sheet exists use the function below.

Function SheetExists(ByVal sheetname As String, ByVal wrkbookname As String) As Boolean

'*** Code from VisibleVisual.com ********

On Error Resume Next
SheetExists = False

Dim ws As Worksheet
Dim newSheetName As String
newSheetName = sheetname

For Each ws In Workbooks(wrkbookname).Worksheets

If ws.name = newSheetName Or newSheetName = "" Then
IsSheetThere = True
'MsgBox "Sheet exists or name is invalid", vbInformation

Exit Function
End If

End Function

Sign up now and upload your code to the website.

Help us to continue.....
Articles View Hits
Latest Articles