RAJAQ
12/14/2016 - 12:02 PM

add sheet if does not exist

add sheet if does not exist

Option Explicit

Sub CheckSht()

Dim mySheetName As String
Dim mySheetNameTest As String

mySheetName = "MyTestSheet"
    
On Error Resume Next

mySheetNameTest = Worksheets(mySheetName).Name
    If Err.Number = 0 Then
        MsgBox "The sheet named ''" & mySheetName & "'' DOES exist in this workbook."
    Else
        Err.Clear
        Worksheets.Add.Name = mySheetName
        MsgBox "The sheet named ''" & mySheetName & "'' did not exist in this workbook but it has been created now."
    End If

End Sub