Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default vba coding question

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro/VB coding question melExcel2007 Excel Discussion (Misc queries) 3 June 4th 10 11:16 PM
Coding Question Jcraig713 Excel Programming 1 April 2nd 09 09:58 PM
VBA Coding Question Matt Excel Programming 3 January 30th 08 12:03 PM
Coding question bach Excel Programming 4 September 19th 05 08:59 PM
coding question No Name Excel Programming 1 September 28th 04 05:26 PM


All times are GMT +1. The time now is 06:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"