orCode:Dim wsSheet As Worksheet On Error Resume Next Set wsSheet = Sheets("NewShtL") On Error GoTo 0 If Not wsSheet Is Nothing Then MsgBox "I do exist" Else MsgBox "I do NOT exist" End If
These aren't my snippets, I've just nicked them from elsewhere but they illustrate the two different ways that spring to mind to check wether something exists in VBA.Code:Dim sh As Worksheet, flg As Boolean For Each sh In Worksheets If sh.Name Like "NewSht*" Then flg = True: Exit For Next If flg = True Then MsgBox "Found!" Else Sheets.Add.Name = "NewSht" End If


Reply With Quote