Determine If Sheet Name Used

  • Hi

    I am struggling with coming up with a way of writing a line of code in VBA that ignores (or skips) a bit of code everytime a worksheet does not exist.

    Does anyone have any solutions to this?


  • Re: Ignore If Worksheet Does Not Exist

    Here is the code:

  • Re: Ignore If Worksheet Does Not Exist

    I did not test this much, but I think it should work

    Function SheetExists(WB As Workbook, WorkSheetName As String) As Boolean
        Dim WS As Worksheet
        SheetExists = False
        For Each WS In WB.Sheets
            If WS.Name = WorkSheetName Then
                SheetExists = True
                Exit Function
            End If
    End Function

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!