VLOOKUP variable workbook name

BarneyLTD

New Member
Joined
Sep 27, 2017
Messages
26
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 :)
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,729
Office Version
  1. 365
Platform
  1. Windows
Try:
VBA Code:
ActiveCell.FormulaR1C1 = Replace("=VLOOKUP(RC1,'Order Processor V4 @var_date.xlsb'!List[[Column1]:[Column6]],6,0)", "@var_date", Format(Date, "DDMMYY"))
 

Watch MrExcel Video

Forum statistics

Threads
1,127,611
Messages
5,625,822
Members
416,138
Latest member
Pizzaman22

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
Top