Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Good question! I think this (untested) code should handle all the
possibilities... Function GetDate(D As Date) As Date GetDate = D Do GetDate = GetDate + (Weekday(GetDate, vbMonday) 5) + _ (Weekday(GetDate, vbMonday) 6) GetDate = GetDate + IsHoliday(GetDate) Loop While Weekday(GetDate, vbMonday) 5 Or IsHoliday(GetDate) End Function -- Rick (MVP - Excel) "Joel" wrote in message ... Rick How do you handle the case when the data is a monday and a holiday is on Friday. Or the date is Saturday and and the prior Thursday is Thanksgiving? "Rick Rothstein" wrote: I think this will do what you want... Function GetDate(D As Date) As Date GetDate = D + (Weekday(D, vbMonday) 5) + (Weekday(D, vbMonday) 6) GetDate = GetDate + IsHoliday(GetDate) End Function Note that I do not make use of your IsWeekend function in this code... I only use your IsHoliday function. Also note those plus signs are all correct (VB True values evaluate to -1, so adding them subtracts days). -- Rick (MVP - Excel) "thomas donino" wrote in message ... I have a date in a cell which I need to check for whether or not it is a weekend day or a holiday. I have a function to do each, my question is how do I construct the loop to check first if its a weekend day and if so run again to see if the day prior is a weekend day and then if that is also a weekend day to check if day prior again is a holiday. If it is, return the next prior day and if not then return that day. I already built the Isweekend and Isholiday functions. Thank you in advance |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro/VB coding question | Excel Discussion (Misc queries) | |||
Coding Question | Excel Programming | |||
VBA Coding Question | Excel Programming | |||
Coding question | Excel Programming | |||
coding question | Excel Programming |