VLookup with VB?

jsambrook

Board Regular
Joined
Feb 1, 2010
Messages
214
I want to email suppliers a spreadsheet printed to PDF. I have all email addresses in a spreadsheet and I want to be able to do a vlookup from the spreadsheet within the macro to use the email address to send. I have the majority of the code sorted, its just the looking up of the email that I'm struggling with. My supplier spread has supplier name and email address and my spread has the Supplier name in a cell on the spreadsheet.
thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Are you looping through the supplier list when creating the worksheets to send out?

If you are then you could grab the email when you do that and use it to send the worksheet.
 
Upvote 0
Code:
ANS = Application.WorksheetFunction.VLookup(Range("F3").Value, Range("AP:AQ"), 2, 0)

How about this
 
Upvote 0
Prajul89

that looks like it could work, except I need to reference another worksheet, where can I put the filepath etc?

Norie

I wish I could do that, but its a short term fix using somebody elses code from a datbase extraction and they have yet to insert the email field!
 
Upvote 0
Code:
ANS = Application.WorksheetFunction.VLookup(Workbooks(YOURFILE).Sheets(YOURSHEET).Range("F3").Value, Workbooks(YOURFILE).Sheets(YOURSHEET).Range("AP:AQ"), 2, 0)

Just put your FileName and SheetName and you are good to go.
 
Upvote 0
I want to run this macro from my personal workbook. Is there any way I can insert the spreadsheet with the suppliers names into my personal workbook somewhere? There are too many to hard code. Might just be best to open the workbook to reference from it and close it again.
 
Upvote 0
Can't you create a list of suppliers/emails?

You've got all the data so that shouldn't be to hard.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,553
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