VLOOKUP/MACRO referencing data in a report dated 1 day previous.

Rhinogaz

New Member
Joined
Dec 18, 2019
Messages
8
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Hi All I am trying to write a VLOOKUP formula in a macro run from a template report to Return data from yesterdays report (which started life as the template then saved as that days report). The normal VLOOKUP formula works fine normally when both reports are open. I wanted to automate the process as much as possible which is why I wanted to incorporate the formula in a macro. The date in the file is displayed as "Report 19.12.19.xls". When I run the macro it stops with a compile error: Sub or Function not defined and highlights TODAY in the formula. Can anyone help please?

VBA Code:
' ActiveCell.FormulaR1C1 = _
    '   "=VLOOKUP(C12,INDIRECT("[Offline Report_"&TEXT(TODAY()-1,"DD.MM.YY")&".XLS]Offline Tuesday to Friday Repor'!C12:C17,6,FALSE))
 
You can't VLOOKUP(L:L... - that's what's giving you the #REF error. You look up one value, not en entire column. Something like =VLOOKUP(L1,...

The formula I sent you was directly into the cell (not vba) and I have just typed it in again to take a copy of the formula and it works returning a comment from yesterdays report. On this one I have left in the dollar signs-

VBA Code:
=VLOOKUP($L:$L,'[Offline report 30.12.19.xls]Offline Tuesday to Friday Repor'!$L:$Q,5,FALSE)

It does work, I will try with the cell ref: as you suggest and see if that works.

Thanks
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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