Jugulator
8/14/2018 - 12:21 PM

Sheet Exists

Function SheetExists(ByVal SheetToFind As String, ByVal wb As Workbook) As Boolean
'   Description: ellenõrzi, hogy egy adott nevû munkalap létezik-e
'   Inputs:      lap elnevezése, melyik munkafüzetben
'   Outputs:     true/false

    SheetExists = False
    
    Dim sht As Variant
    For Each sht In wb.Worksheets
        If SheetToFind = sht.Name Then
            SheetExists = True
            Exit Function
        End If
    Next sht

End Function

Function SheetExists(ByVal SheetToFind As String, Optional ByVal wb As Workbook) As Boolean
'   Description: ellenõrzi, hogy egy adott nevû munkalap létezik-e
'   Inputs:      lap elnevezése, melyik munkafüzetben
'   Outputs:     true/false

     If wb Is Nothing Then Set wb = ThisWorkbook

     On Error Resume Next
        Dim sht As Worksheet
        Set sht = wb.Sheets(shtName)
     On Error GoTo 0

     SheetExists = Not sht Is Nothing

End Function