繁体   English   中英

Excel VBA .Find()错误

[英]Excel VBA .Find() error

我有以下一段VBA代码,但是运行它时,我得到了无限MsgBoxes,在ID地址上方4行向我显示相同的地址。 我必须使用Ctrl + Break停止执行。

我一直在尝试使代码正常工作,在我看来,该错误来自Find()方法。 在我的代码的其他版本中,我得到对象“ Range”的“方法'Find'失败。有关如何解决此问题的任何想法?谢谢。

Function CheckFinancials(ID As Integer) As Double
    Dim MyArray(1 To 4) As Integer
    Dim Guide As Range
    Set Guide = Worksheets("Financials").Range(Cells(1, 1),Cells(Worksheets("Financials").UsedRange.Rows.Count, 1))
    Set Guide = Guide.Find(ID)

    MsgBox Guide.Address

您的发现缺少很多参数(尝试记录下来,您将看到),测试一下:

Function CheckFinancials(ID As Integer) As Double
    Dim MyArray(1 To 4) As Integer
    Dim Guide As Range
    Set Guide = Worksheets("Financials").Range(Cells(1, 1), Cells(Worksheets("Financials").UsedRange.Rows.Count, 1))
    Set Guide = Guide.Find(What:=ID, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

    MsgBox Guide.Address

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM