Using a macro to find..

jharcourt1

New Member
Joined
Dec 10, 2010
Messages
9
Hi all,

Need a bit of help with a macro to produce find results:

Basically i need whatever is entered into cell B8 to be found elsewhere in the spreadsheet and have the cell beneath that copied.

Its a basic address search function, you type the name of the business into cell B8, click the created 'Button A' it will locate the company name elsewhere on the spreadsheet and copy the cell beneath it (postcode).

The reason the copy is required is for a search on the internet to verify, so basically all you have to do in order to obtain postcode is type the company name and then the button.

Any help?

Cheers,
James
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try this: change C8 to suit

Rich (BB code):
Sub cpy()
Dim Found As Range
Set Found = Cells.Find(what:=Range("B8").Value, after:=Range("B8"), LookIn:=xlValues, lookat:=xlWhole)
If Not Found Is Nothing Then Found.Offset(1).Copy Destination:=Range("C8")
End Sub
 
Upvote 0
Press ALT + F11 to open the Visual Basic Editor. Select Module from the Insert menu, copy the code and paste it into the white space on the right. change C8 to the cell that you want the result in. Press ALT + Q to close the code window.

Press ALT + F8, click on cpy then click the Run button.
 
Upvote 0
Sorry, i dont want the result anywhere.. i literally would like the macro to find what is in B8 somewhere else in the spreadsheet and copy the cell beneath it.
 
Upvote 0
Then try

Code:
Sub cpy()
Dim Found As Range
Set Found = Cells.Find(what:=Range("B8").Value, after:=Range("B8"), LookIn:=xlValues, lookat:=xlWhole)
If Not Found Is Nothing Then Found.Offset(1).Copy
End Sub
 
Upvote 0
It works for me. Maybe

Code:
Sub cpy()
Dim Found As Range
Set Found = Cells.Find(what:=Range("B8").Value, after:=Range("B8"), LookIn:=xlValues, lookat:=xlWhole)
If Not Found Is Nothing Then
    Found.Offset(1).Copy
Else
    MsgBox "Not found"
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

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