Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Calculating a Due Date that is not a holiday or weekend

This should get you started;

Public Function GetDate_WorkingDay(StartDate As Date, DaysToAdd As Long) As
Date
Dim TestDate As Long 'Date

Dim Hols(1 To 5) As Long
'Just creat some holidays
Hols(1) = DateSerial(2006, 12, 25)
Hols(2) = DateSerial(2006, 12, 26)
Hols(3) = DateSerial(2006, 12, 27)
Hols(4) = DateSerial(2007, 1, 1)
Hols(5) = DateSerial(2007, 1, 2)

TestDate = DateAdd("d", DaysToAdd, StartDate)

Do Until IsWorkingDay(TestDate, Hols()) = True
TestDate = TestDate + 1
Loop

GetDate_WorkingDay = TestDate

End Function


Private Function IsWorkingDay(DateToCheck As Long, HolidayDates() As Long)
As Boolean
Dim i As Long

'Assume failure
IsWorkingDay = False

If Weekday(DateToCheck, vbMonday) 5 Then
Exit Function
End If

For i = LBound(HolidayDates) To UBound(HolidayDates)
If DateToCheck = HolidayDates(i) Then
Exit Function
End If
Next

'Get here, then OK
IsWorkingDay = True

End Function

NickHK

wrote in message
ups.com...
Ok Thank you. I just can't figure you how the code is written. I can
write some code but I am having issues with this one. I am going to
put it right out there.

Does anyone have any code already written that performs the function I
am looking for?

Thanks,



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
Count days but solutions can't land on holiday or weekend NB292 Excel Discussion (Misc queries) 4 February 7th 09 10:35 AM
formual to determine if date falls on weekend, adjust date to Mond Bradley Excel Discussion (Misc queries) 4 November 21st 08 06:19 PM
Removing weekend/holiday dates - cont'd GR Charts and Charting in Excel 4 January 10th 08 09:09 PM
Invalid date if weekend or bank holiday grobertson Excel Worksheet Functions 7 June 14th 07 03:24 PM
Coding to show first _weekday_ prior to a date, when date calculation happens to fall on weekend? StargateFan[_3_] Excel Programming 5 December 9th 04 09:06 AM


All times are GMT +1. The time now is 08:20 PM.

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"