How to Determine If a Sheet Exists Within a Workbook Using VB
- 1). Open Microsoft Excel.
- 2). Click "Tools," "Macro" and then click "Visual Basic." This will open the VB editor.
- 3). Click "Insert," then "Module." You are now in a programming code module.
- 4). Type or copy-and-paste the following code:
Sub DoesSheetExist()
Dim wSheet As Worksheet
On Error Resume Next
Set wSheet = Sheets("Sheet1")
If wSheet Is Nothing Then
MsgBox ("Worksheet does not exist")
Else 'Does exist
MsgBox ("Sheet 1 does exist")
End If
End Sub - 5). Press "F5" to run the program. It should tell you if Sheet 1 exists or does not exist in your Excel workbook.
Source...