VBA in find function runtime error 91

♀尐吖头ヾ 提交于 2019-11-29 13:08:18
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.

You use SET to find a cell and put it in an object. But you can let SET out if you just waht the Row. This is how I would write that test so far:

Dim Rw As Long

On Error Resume Next
Rw = Workbooks(theFile).Worksheets(1).Columns(1).Find _
    ("Summary", LookIn:=xlValues, LookAt:=xlPart).Row

If Rw > 0 Then
    MsgBox "The row is " & Rw
Else
    MsgBox "Not found"
End If
aileen
Sub search()

    Sheets("MyShelf").Activate

    Dim dd() As String

    aa = Cells(Rows.Count, 1).End(xlUp).Row

    ReDim dd(aa)

    i = 1

    Range(Cells(2, 1), Cells(aa, 1)).Select

    Set bb = Selection

    For Each cc In bb

        dd(i) = cc.Value

        i = i + 1

    Next

    Sheets(50).Activate

    ff = 0

        For i = 1 To aa - 1

        ee = Range("D:D").Find(What:=dd(i), LookAt:=xlPart, LookIn:=xlValues, SearchOrder:=xlByColumns)

        On Error Resume Next

        If Len(ee) > 1 Then

        ff = ff + 1

        End If

    Next

    MsgBox ff


End Sub
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!