VLOOKUP and Variable Workbook using VBA

msquared99

Board Regular
Joined
Mar 8, 2012
Messages
52
I'm a bit bumfuzzled here with a macro using VLOOKUP. I am making the formula actually look up a value to the left. Maybe the FIND method would be better?

Workbook1 is opened by the macro and given the name "FileName" because the name is variable.

Workbook2 is run from a database and it's name is "Red Flag Report", its name never changes and is the active workbook at this time.

Here is the formula as I invision it:

Worksheets("Sheet1").Range("E3").Formula = "=vlookup(d4,choose({2,1}," & Filename.Sheet1.range("$D$3:$D & lastRow1")"& , &"" & Filename.sheet1.range("$h$3:$h & lastRow1")",2,0)"

What would the proper VBA syntax be?

Thanks!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,203,078
Messages
6,053,405
Members
444,662
Latest member
AaronPMH

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