Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
On Wed, 1 Feb 2006 17:25:39 -0600, dannyboy213
wrote: Please do. "Ron Rosenfeld" wrote in message .. . On Wed, 1 Feb 2006 15:01:37 -0600, dannyboy213 wrote: How do I calculate business days without using the analysis Tool-Pak. Is it permissible to use a UDF (User Defined Function)? It would get distributed with the workbook. I had written one for just such an issue, and it basically mimics the Workday Function. If that would be helpful, I'd be happy to post it again. --ron To enter, <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, enter =WD(start_date, num_days, [holidays]) into some cell. The optional 'holidays' argument must be entered as a cell (range) reference, however. ================================== Function WD(StartDate As Date, ByVal NumDays As Long, _ Optional Holidays As Range = Nothing) As Date 'Workday function without Analysis Toolpak 'However, Holidays must be in a range Dim i As Long Dim TempDate As Date Dim c As Range Dim Stp As Integer Stp = Sgn(NumDays) TempDate = StartDate For i = Stp To NumDays Step Stp TempDate = TempDate + Stp If Weekday(TempDate) = vbSaturday Then _ TempDate = TempDate + Stp - (Stp 0) If Weekday(TempDate) = vbSunday Then _ TempDate = TempDate + Stp + (Stp < 0) If Not Holidays Is Nothing Then Do Until Not IsError(Application.Match(CDbl(TempDate), Holidays, 0)) = False If IsError(Application.Match(CDbl(TempDate), Holidays, 0)) = False Then TempDate = TempDate + Stp If Weekday(TempDate) = vbSaturday Then _ TempDate = TempDate + Stp - (Stp 0) If Weekday(TempDate) = vbSunday Then _ TempDate = TempDate + Stp + (Stp < 0) End If Loop End If Next i WD = TempDate End Function =================================== --ron |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
With this business with ONLY 5,- EUR OVER 61,370 EUR in 3 months earn!! | Charts and Charting in Excel | |||
With this business with ONLY 5,- EUR OVER 61,370 EUR in 3 months earn!! | Charts and Charting in Excel | |||
How do I install Excel 2000 Analysis Tool Pak? | Excel Discussion (Misc queries) | |||
How do I install Excel 2000 Analysis Tool Pak? | Excel Discussion (Misc queries) | |||
How do I get Data Analysis Plus tool pack in tools menu Show up. . | Setting up and Configuration of Excel |