I'm automating a large number of emails which deliver KPIs and backing data to managers on a daily basis.
How do I get NETWORKDAYS(startdates, enddates, holidays) to use the range holidays on another Excel workbook?
The whole process is:
- Task scheduler opens an XLSM file daily.
- The XLSM file opens a csv output, edits and analyses it - including using NETWORKDAYS.
- The csv file is then emailed out, with an email that reports the KPI it calculates.
I want to make sure holidays is kept on one Excel workbook only, separate from the xlsm files, because there are going to be many such xlsm files scheduled - if holiday dates change, I only want to have to update one range.
I have tried a number of things using with, set, named ranges. (I've only used VBA for a few days, so may be missing something obvious, however.)
Range("F2").Select
ActiveCell.FormulaR1C1 = _
"=MAX(NETWORKDAYS([@[Effective Requested Date]], [@[Scheduled Date]], holidays), NETWORKDAYS([@[Effective Requested Date]], [@ExamDate], holidays))"
My NETWORKDAYS column outputs as #VALUE. I am expecting the output to be a whole number.