View Single Post
  #6   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default

On Fri, 17 Jun 2005 15:56:24 -0500, myplaygroundismyoffice
wrote:

Ok, I do not have access to the MS Excel CD to install this with. Is
there a way to download it from a MS website, or am I going to have to
hunt down the program install cd for this? (egads, I hope not! I have
no idea where that thing went!!!!) Anyway, I'm about ready to just
forget it and use a calendar so I can just get it done and off my to-do
list. Any ideas for a formula that would do this without having to use
the add in toolpak? Thanks for the response!!! -VB


Here is a UDF that does not require the ATP to be installed. It was written to
be a bit more flexible than the WORKDAY function, but you can use it in a
similar fashion.

To enter this, <alt<F11 opens the VB Editor. Ensure your project is
highlighted in the Project Explorer window, then Insert/Module and paste the
code below into the window that opens.

To use this, enter a formula of the type:

=WrkDay(StartDate,NumDays,Holidays)

The Holidays argument is optional and, if present, refers to a range where you
have the holiday dates listed.


===========================
Function WrkDay(StartDate As Date, ByVal NumDays As Long, _
Optional Holidays As Range = Nothing, _
Optional WeekendDay_1 As Integer = 1, _
Optional WeekendDay_2 As Integer = 7, _
Optional WeekendDay_3 As Integer = 0) As Date

' Sunday = 1; Monday = 2; ... Saturday = 7

Dim i As Long
Dim TempDate As Date
Dim Stp As Integer
Dim NonWrkDays As Long
Dim temp As Long, SD As Date, ED As Date

Stp = Sgn(NumDays)

'Add NumDays
TempDate = StartDate + NumDays

'Add Non-Workdays

Do While Abs(NumDays) < temp
SD = Application.WorksheetFunction.Min(StartDate + Stp, TempDate)
ED = Application.WorksheetFunction.Max(StartDate + Stp, TempDate)

temp = NWrkDays(SD, ED, Holidays, WeekendDay_1, WeekendDay_2, WeekendDay_3)
TempDate = TempDate + NumDays - Stp * (temp)
Loop

WrkDay = TempDate
End Function
=======================


--ron