VLOOKUP variable workbook name

BarneyLTD

New Member
Joined
Sep 27, 2017
Messages
27
Hi all, hope everyone is doing well during this time?

Can anyone help solve an issue i am having?
I have started to set up a excel add-in with some macros I use most often but have hit a wall with trying to use a variable workbook name in a vlookup.

The below code is what is currently inserted but the date on the workbook changes depending on the date so 120220 would need to somehow be set to a variable to use today's date. I have tried to use the Today() function but can't seem to figure out the correct way. This workbook is open while the lookup is performed.

VBA Code:
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,'Order Processor v4 [COLOR=rgb(0, 0, 0)]120220[/COLOR].xlsb'!List[[Column1]:[Column6]],6,0)"

Thanks :)
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try:
VBA Code:
ActiveCell.FormulaR1C1 = Replace("=VLOOKUP(RC1,'Order Processor V4 @var_date.xlsb'!List[[Column1]:[Column6]],6,0)", "@var_date", Format(Date, "DDMMYY"))
 
Upvote 0

Forum statistics

Threads
1,214,885
Messages
6,122,090
Members
449,065
Latest member
Danger_SF

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