26 | 04 | 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
Next

End Function
Login

Sign up now and upload your code to the website.

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