VLOOKUP Expeected: end of statement Error

Jett Midknight

Board Regular
Joined
Jan 8, 2014
Messages
110
Hello all. So I am trying to run a vlookup from yesterdays file, however as I want the file name to be easily changed, I have assigned it to a variable, rather than having to change 10 lines of code every time you want to change the name. The problem I am running into is getting an excepted end of statement error. I'm sure it is simple as a misplaced comma or quotation, but I can't seem to find it. Any help would be appreciated.

Code:
Dim FN As String
FN = "Test Schedule "

Range("C2").FormulaR1C1 = _
        "=VLOOKUP(RC[-2],'[FN & Format(Application.WorkDay(Date, -1), "m-dd-yy") & ".xlsx]Schedule'!R1C1:R101C4,4,FALSE)"

I have also tried it in this form, but it then won't recognize that yesterdays file is open.
Code:
Dim FN As String
FN = "Test Schedule "

Range("C2").FormulaR1C1 = _
        "=VLOOKUP(RC[-2],'[FN" & Format(Application.WorkDay(Date, -1), "m-dd-yy") & ".xlsx]Schedule'!R1C1:R101C4,4,FALSE)"
 
I managed to fix it. Apparently the proper format it

Code:
[COLOR=#333333]Range("C2").FormulaR1C1 = _
[/COLOR][COLOR=#333333]        "=VLOOKUP(RC[-2],'[" & FN & Format(Application.WorkDay(Date, -1), "m-dd-yy") & ".xlsx]Schedule'!R1C1:R101C4,4,FALSE)"[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,226,834
Messages
6,193,214
Members
453,779
Latest member
C_Rules

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