.Find function trigger's error

bradgar

Board Regular
Joined
Aug 29, 2011
Messages
78
I am trying to have a sub to take data from one sheet and place in another. The variable to look for is from the sheet I need to fill, the lookup of the info (based on that number) is on the other.

Code:
Private Sub trKr_Click()
Dim rga As String
Dim fC As Range
Range("H8").Value = InputBox("Please enter the RGA number you want to Track", "RGA Tracker")
rga = Sheets("RGA Overview").Range("H8").Value
cusT = Sheets("RGA Overview").Range("E10").Value

With Application
    ScreenUpdating = False
        With ActiveWorkbook
            With Sheet2
                .Activate
                Set fC = Cells.Find(What:=rga, after:=Range("A1"), LookIn:=xlValues, lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=False)
                    'fC.Select
                MsgBox fC & " " & fC.Row & " " & rga
                cusT = Sheets("RGA Information").Range("D" & fC.Row).Value
            End With
        End With
    ActiveWorkbook.Sheets("RGA Overview").Select
    ScreenUpdating = True
End With
End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
It's actually " Set fC = Columns(1).Find.....

and it returns Object Variable or With block variable not set. Runtime 91

I have code just like this in other workbooks and it works perfectly but for some reason it is not recognizing my object here. The entry I type in exists, and in Column 1 ....
 
Upvote 0
Figured it out.

Code:
With Application
    ScreenUpdating = False
        With ActiveWorkbook
                Set fC = Worksheets("RGA Information").Columns("A").Find(What:=rga, After:=Range("A1"), LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=False)
                MsgBox fC & " " & fC.Row & " " & rga
                Worksheets("RGA Overview").Select
                Sheets("RGA Overview").Range("E10").Value = Sheets("RGA Information").Range("D" & fC.Row).Value
 
Upvote 0

Forum statistics

Threads
1,224,591
Messages
6,179,768
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top