选项显式 - 无法识别标签(错误处理程序GoTo)

时间:2015-10-06 07:06:35

标签: vba

我已经制作了一个UDF,在Option Explicit的模块中非常简单,我在标签用作错误处理的目标时遇到了错误:

  

编译错误:Sub或Function未定义

以下是代码:

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

我环顾四周,但我似乎无法找到解决办法......

1 个答案:

答案 0 :(得分:1)

您在:代码

后缺少ErrHdl
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