VBA中查找功能运行时错误91 [英] VBA in find function runtime error 91

查看:373
本文介绍了VBA中查找功能运行时错误91的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是关于VBA for excel中的运行时错误91。我做了一些搜索无效。我的代码如下我注意到导致错误的部分。为什么会发生这种情况,我该如何解决这个问题呢?

  Sub RemoveFooterRows(theFile)
Dim作为范围
Dim aggregateRow

''错误来自以下部分
found = isItRow =工作簿(theFile).Worksheets(1).Columns(1).Find _
(Summary,Range(A1),xlValues,xlPart,xlByRows,xlNext,False,,False)
''错误来自上面的

MsgBox(val是& found.Row)

End Sub


解决方案

  Sub RemoveFooterRows(theFile)

Dim found As Range

Set found = Workbooks(theFile).Worksheets (1).Columns(1).Find _
(Summary,Range(A1),xlValues,xlPart,xlByRows,xlNext,False,,False)
MsgBox(val is & found.Row)

End Sub

您需要设置关键字分配值。



也不知道你想要什么= isItRow =要做,但你应该在两个语句中做,而不是试图堆栈它们。



另外aggregateRow不使用,没有分配一个类型。


My question is concerning the runtime error 91 in VBA for excel. I've done some searching to no avail. My code is below. I have noted the section causing the error. Why is this happening, and how can i fix it and move on?

Sub RemoveFooterRows(theFile)
    Dim found As Range
    Dim aggregateRow

    ''Error is from section below
    found = isItRow = Workbooks(theFile).Worksheets(1).Columns(1).Find _
        ("Summary", Range("A1"), xlValues, xlPart, xlByRows, xlNext, False, , False)
    ''Error is from section above

    MsgBox ("val is " & found.Row)

End Sub

解决方案

Sub RemoveFooterRows(theFile)

    Dim found As Range

    Set found = Workbooks(theFile).Worksheets(1).Columns(1).Find _
        ("Summary", Range("A1"), xlValues, xlPart, xlByRows, xlNext, False, , False)
    MsgBox ("val is " & found.Row)

End Sub

You need the "Set" keyword to assign the value.

Also not sure what you want " =isItRow =" to do but you should do it in two statements instead of trying to stack them like that.

Also aggregateRow isn't used and isn't assigned a type.

这篇关于VBA中查找功能运行时错误91的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆