Hi everyone,
I’m working on a VBA function to calculate the number of days between 2 dates (eg: how many Mondays, Tuesdays, Sat & Sun, public holidays, weekends (including Sat & Sun) and public holidays.
The syntax is howmanydays(“end date”, “start date”, sw)
Sw = 0 to 9
Sw = 0 (to calc number of the Sat & Sun
Sw = 1 (Sun)
Sw = 2 – 7 (Mon - Sat)
Sw = 8 (to calc the number of public holidays
Sw = 9 (to work out how many public holidays + Sat + Sun
Currently, the function only gives me correct answers on the number of Sat & Sun (sw = 0). If I use other numbers (1 – 9) the function gives me incorrect results.
Also, if I delete a holiday within the range (between start date and end date) the function does not refresh its calculation.
Can someone please help me find out where I went wrong?
I enclose a sample workbook for your reference. Thanks for your kind assistance.
Regards
KP