Search, Copy, and Paste Macro

Ore_Ele

New Member
Joined
Jul 27, 2011
Messages
5
I'm trying to make an ELO calculator, but I don't know much about macros (other than the recording feature).

How can I take the contents from cell A4 (on sheet 1), search for it (exact search) on sheet 2, copy the contents of the cell 2 columns over of the search result, and paste those results in cell B2 (on sheet 1)?

When I try doing a record action for the macro, it doesn't copy the search result cell as such but just that cell (so if the result is A13 when I'm recording, it will always do A13, regardless of what search results it gets).

Any help would be greatly appreciated.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Possibly

Code:
Sub test()
Dim Found As Range
Set Found = Sheets("sheet2").Find(what:=Sheets("Sheet1").Range("A4").Value, LookIn:=xlcalues, lookat:=xlWhole)
If Not Found Is Nothing Then Found.Offset(, 2).Copy Destination:=Sheets("Sheet1").Range("B2")
End Sub
 
Upvote 0
Possibly

Code:
Sub test()
Dim Found As Range
Set Found = Sheets("sheet2").Find(what:=Sheets("Sheet1").Range("A4").Value, LookIn:=xlcalues, lookat:=xlWhole)
If Not Found Is Nothing Then Found.Offset(, 2).Copy Destination:=Sheets("Sheet1").Range("B2")
End Sub

Thank you very much.

I'm getting a Run-Time error '438':

Object doesn't support this property or method

For line 2 (starting with "Set Found = ...")

Would it make a difference that it is searching for words, not numbers?
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,266
Members
452,902
Latest member
Knuddeluff

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