Quote Originally Posted by GTO View Post
Hi Fabrizio,

Apologies, I forgot to include the Function, which would go in a Standard Module

Function ShExists(ShName As String, _
                  Optional wb As Workbook, _
                  Optional CheckCase As Boolean = False) As Boolean
    
    If wb Is Nothing Then
        Set wb = ThisWorkbook
    End If
    
    If CheckCase Then
        On Error Resume Next
        ShExists = CBool(wb.Worksheets(ShName).Name = ShName)
        On Error GoTo 0
    Else
        On Error Resume Next
        ShExists = CBool(UCase(wb.Worksheets(ShName).Name) = UCase(ShName))
        On Error GoTo 0
    End If
End Function
:

This way we check to make sure the sheet exists before working with it.

Mark
Thanks