Filepath to include today's date within vlookup - excel vba

AxMan

New Member
Joined
Apr 16, 2015
Messages
19
Hi All,

I'm basically trying to vlookup values in a spreadsheet, where the spreadsheet has a static title and today's date is included on the end of the static title like so - "Title DD/MM/YYYY".

I am however getting an error on the line highlighted in red (Compile error: syntax error), any help is much appreciated

Sub VlookupAvailability()


'Find last row
LastRow = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count


Workbooks("Stock Availability for Company.xlsm").Activate
Sheets("A").Select


'Vlookup available stock
Range("K2").Formula = "=IFERROR(VLOOKUP($B2,'C:xxxx\["Title " & Format(Date, "DDMMYYYY") & ".xlsx"]Sheet1'!$A:$L,12,0),0)"
Range(Cells(2, 11), Cells(LastRow, 11)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial xlPasteValues


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).
Code:
[COLOR=#FF0000]Range("K2").Formula = "=IFERROR(VLOOKUP($B2,'C:xxxx\[[U][B]"[/B][/U]Title " & Format(Date, "DDMMYYYY") & ".xlsx[U][B]"[/B][/U]]Sheet1'!$A:$L,12,0),0)"[/COLOR]

Has unnecessary quote marks - try:

Code:
[COLOR=#FF0000]Range("K2").Formula = "=IFERROR(VLOOKUP($B2,'C:xxxx\[Title " & Format(Date, "DDMMYYYY") & ".xlsx]Sheet1'!$A:$L,12,0),0)"[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,203,521
Messages
6,055,891
Members
444,831
Latest member
iceonmn

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