退出功能时对象必填错误

时间:2019-05-10 00:13:56

标签: excel vba

我的函数采用由Excel公式单元格引用组成的字符串,并将行部分返回(例如,“ = $ E23”返回“ 23”)给调用函数。它获得正确的值,但是当它到达“结束函数”行时,它给了我Object Require错误。这让我发疯。我不记得曾经见过这个。

我在循环中使用了干净的Exit For,但我认为这是导致问题的原因

Function GetNumber(Address As String) As String
    Dim i As Integer
    Dim temp As Integer
    Dim number As String

    For i = 1 To Len(Address)
        If IsNumeric(Mid(Address, i, 3)) Then
            temp = temp + 1
            If temp = 1 Then
                GetNumber = Mid(Address, i, 3)
            End If
        End If
    Next
End Function

Iterating through cells, reading/extracting from the formula to get the row (GetNumber) and then rewriting the formula with a new column letter

0 个答案:

没有答案