Find based on data in a cell in a different workbook

jdawg44

New Member
Joined
Jan 31, 2008
Messages
13
Hello,

I am trying to use the following code to find a cell in Row 1 of Book1. The data I am searching for is whatever is in cell K1 of the workbook with the variable name wb1.

Code:
Workbooks(wb1).Activate
    Range("K1").Activate
Workbooks("Book1.xls").Activate
    Rows("1:1").Select
    Selection.Find(What:=Workbooks(wb1).ActiveCell.Value, After:=ActiveCell, LookIn:=xlValues, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

This code is giving me a "runtime error 438: Object doesn't support this property or method". Any help would be appreciated.
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

jdawg44

New Member
Joined
Jan 31, 2008
Messages
13
Nevermind. I found out my issue. I was only defining the workbook, not the worksheet. the following code worked for me:

Code:
    Selection.Find(What:=Workbooks(wb1).Worksheet(sh1).Range("K1"), After:=ActiveCell, LookIn:=xlValues, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
 

Watch MrExcel Video

Forum statistics

Threads
1,123,489
Messages
5,601,986
Members
414,489
Latest member
Xlambda

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
Top