Find based on cell contents??

M4RSHMAN85

New Member
Joined
Feb 25, 2023
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
Hi All,

Currently working through creating some invoice automation and I've run in to a spot with locate the customers address based on a variable name. Here is what I've come up with so far. Any help would be great - Thank you.

Sub Macro5()
'
' Macro5 Macro
'

'Get Name'
Windows("BOOKS.xlsm").Activate
Range("B3").Select
Selection.End(xlDown).Select
Selection.Copy

'Paste Name'
Windows("Invoice Template.xlsx").Activate
Range("B7:C7").Select
ActiveSheet.Paste
Application.CutCopyMode = False

'Copy Name'
Selection.Copy

'Go To addresses sheet'
Sheets("Invoice Address Book").Select

*****'Find Selection Contents'*****

*****'RANGE IS B3:BA100'*****

Cells.Find(What:="******", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate

'Copy Address'
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy

'Paste Address'
Sheets("Invoice").Select
ActiveSheet.Paste

'Select Name & End'
Range("B7:C7").Select

End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
When you want to find "Selections Contents" what are the "Contents"? What column(s) contain the data that will match the "Contents"?
Can you post a copy of your Workbooks (please make sure any sensitive information is removed)?
 
Upvote 0
When you want to find "Selections Contents" what are the "Contents"? What column(s) contain the data that will match the "Contents"?
Can you post a copy of your Workbooks (please make sure any sensitive information is removed)?
Hi, The contents are the customer name copied from "my books". I have a sheet in my invoice template labelled Invoice Address Book. All my customers in here.
The Range to find the customer name (with the address in the 4-5 rows below it) is RANGE IS B3:BA100. Cols B & C are A, D & E are B etc.

Hope this makes sense?
 
Upvote 0
Good to hear you got the solution.
If you would like to post the solution then it is perfectly fine to mark your post as the solution to help future readers. Otherwise, please do not mark a post that doesn't contain a solution.
 
Upvote 0
For me, I've decided to change my layout and now run a vlookup to return what I need - this is my solution.

The original problem is still unresolved.
 
Upvote 0

Forum statistics

Threads
1,214,870
Messages
6,122,021
Members
449,060
Latest member
LinusJE

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