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.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,282
Messages
5,836,390
Members
430,425
Latest member
xlsee

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