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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
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
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,575
Members
449,089
Latest member
Motoracer88

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