Retroshift
Board Regular
- Joined
- Sep 20, 2016
- Messages
- 119
- Office Version
- 2019
- Platform
- Windows
Hi
I have a counter with a minimum value of 17. As long as this value is not reached, then extra dates should be added to an array of dates.
The extra dates should be workdays: if for example 2 extra dates are needed to reach the 17 value, but the 24th of December is not a workday, yet 23rd and 22nd are a workday, then 23rd and 22nd should be added to the array and not 24th. And so on.
How can I alter the draft VBA code accordingly?
I have a counter with a minimum value of 17. As long as this value is not reached, then extra dates should be added to an array of dates.
The extra dates should be workdays: if for example 2 extra dates are needed to reach the 17 value, but the 24th of December is not a workday, yet 23rd and 22nd are a workday, then 23rd and 22nd should be added to the array and not 24th. And so on.
How can I alter the draft VBA code accordingly?
VBA Code:
Year = ThisWorkbook.Worksheets("Holidays").Range("C4")
If counter <= 16 And Weekday("24/12/" & Year, 2) < 6 Then Redim Arr() to include date ("24/12/" & Year) in an array of dates
If counter <= 15 And Weekday("23/12/" & Year, 2) < 6 Then Redim Arr() to include date ("23/12/" & Year) in an array of dates
If counter <= 14 And Weekday("22/12/" & Year, 2) < 6 Then Redim Arr() to include date ("22/12/" & Year) in an array of dates
If counter = 13 And Weekday("21/12/" & Year, 2) < 6 Then Redim Arr() to include date ("21/12/" & Year) in an array of dates