Create macro to search for a cell value [Closed]

Report
Posts
1
Registration date
Tuesday May 28, 2013
Status
Member
Last seen
May 28, 2013
-
Posts
2742
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
May 4, 2021
-
I have 2 separate excel (2010) workbooks I'm working with and I would like to create a macro that, when run, will copy a variable value that is in cell J1 in workbook 1, and search workbook 2 for that value.

I've tried recording a macro that uses the search box but it doesn't consider the variable value of J1, and always enters the value that the macro was initially recorded with.

Please Help!

1 reply

Posts
2742
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
May 4, 2021
460
Hi Jesanicholls,

First we need to specify the search value.
Start code with:
Dim sValue As String
sValue = Range("J1").Value

Then look for the Cells.Find part of the code and change the text found after What:= into sValue.

If you need further assistance then post your code along with your question.

Best regards,
Trowa

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!