Macro to find cell value in another sheet

kentster

New Member
Joined
Nov 22, 2016
Messages
28
Hi - I spent time trying to find it in the FAQs but I couldn't find the answer. Apologies if it is out there.

I am trying to create a macro which will take the value from the active cell in "Sheet1" and find the matching value in column A in Sheet 2. When it is found, my cursor would be sitting in Sheet 2 on the matched value.
 
@ipbr21054, this is a very old thread, you really should start a new thread.
I think rngY is a poor choice of variable names since rng implies that you would Dim rngY as Range but in reality to make that code work you would need to Dim rngY as String
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
So maybe this is why it doesn’t work for me.
I will keep looking thanks.
 
Upvote 0
@ipbr21054, this is a very old thread, you really should start a new thread.
I think rngY is a poor choice of variable names since rng implies that you would Dim rngY as Range but in reality to make that code work you would need to Dim rngY as String
It is a poor choice, granted, but still should work.
 
Upvote 0
Command button on worksheet,right click then paste code
try putting the below in your command button

VBA Code:
Private Sub CommandButton1_Click()
    select_me
End Sub
Private Function select_me()
    Set b = Worksheets("sheet2").Range("A:A").Find(ActiveCell.Value, lookat:=xlWhole)
    b = b.Row
    Sheets("sheet2").Select
    Sheets("sheet2").Range("a" & b).Select
End Function
 
Upvote 0

Forum statistics

Threads
1,221,537
Messages
6,160,401
Members
451,645
Latest member
hglymph

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