R3uK
R3uK

Reputation: 14537

Option Explicit - Label (Error Handler GoTo) not recognised

I've made an UDF, pretty simple in a module with Option Explicit and I've got the error on the Label use as a target for Error Handling :

Compilation error : Sub or Function not defined

Here is the code :

Public Function IsRowEmpty(ByVal aArray As Variant, ByVal RowNumber As Long) As Boolean
Dim j As Integer
    IsRowEmpty = True
    On Error GoTo ErrHdl:
    For j = LBound(aArray, 2) To UBound(aArray, 2)
        If aArray(RowNumber, j) <> "" Then
            IsRowEmpty = False
            Exit Function
        Else
        End If
    Next j
Exit Function
ErrHdl
    IsRowEmpty = False
End Function

I've looked around, but I can't seem to find a workaround...

Upvotes: 2

Views: 235

Answers (1)

Uri Goren
Uri Goren

Reputation: 13682

You are missing a : after the ErrHdl tag

Public Function IsRowEmpty(ByVal aArray As Variant, ByVal RowNumber As Long) As Boolean
    Dim j As Integer
    IsRowEmpty = True
    On Error GoTo ErrHdl
    For j = LBound(aArray, 2) To UBound(aArray, 2)
        If aArray(RowNumber, j) <> "" Then
            IsRowEmpty = False
            Exit Function
        Else
        End If
    Next j
Exit Function
ErrHdl:
    IsRowEmpty = False
End Function

Upvotes: 1

Related Questions