Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default how can i networkdays date ranges where dates overlap

I have a list of date ranges, start dates to finish dates, they overlap and
sometimes there are date gaps in between.
My question is how do i find out the network days.

example:
Start Date End date ...... start date end date..... start date end date
4/2/08 5/2/08 4/2/08 6/2/08 7/2/08 8/2/08

the dates are in rows and not columns so i need a formula to tell me total
networkdays between all them days.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default how can i networkdays date ranges where dates overlap

On Thu, 7 Feb 2008 05:54:02 -0800, Angelo1803
wrote:

I have a list of date ranges, start dates to finish dates, they overlap and
sometimes there are date gaps in between.
My question is how do i find out the network days.

example:
Start Date End date ...... start date end date..... start date end date
4/2/08 5/2/08 4/2/08 6/2/08 7/2/08 8/2/08

the dates are in rows and not columns so i need a formula to tell me total
networkdays between all them days.


Networkdays won't work on array arguments.

One solution would be to use a UDF that would use NetWorkdays and apply it
sequentially to each range.

To enter this, <alt-F11 opens the VBEditor.

Ensure your project is highlighted in the Project Explorer window, then
Insert/Module and paste the code below into the window that opens.

THEN you MUST select Tools/References and check atpvbaen.xls from the list of
available references.

========================================
Function NWD(StartDt As Range, EndDt As Range, Optional Holidays As Range)
Dim lTemp As Long
Dim i As Long
Dim dStrtTemp() As Date
Dim dEndTemp() As Date
Dim c As Range

If StartDt.Count < EndDt.Count Then
NWD = CVErr(xlErrValue)
Exit Function
End If

ReDim dStrtTemp(1 To StartDt.Count)
ReDim dEndTemp(1 To StartDt.Count)
i = 1
For Each c In StartDt
dStrtTemp(i) = c.Value
i = i + 1
Next c

i = 1
For Each c In EndDt
dEndTemp(i) = c.Value
i = i + 1
Next c

If Holidays Is Nothing Then
For i = 1 To UBound(dStrtTemp)
lTemp = lTemp + networkdays(dStrtTemp(i), dEndTemp(i))
Next i
Else
For i = 1 To UBound(dStrtTemp)
lTemp = lTemp + networkdays(dStrtTemp(i), dEndTemp(i), Holidays)
Next i
End If

NWD = lTemp
End Function
====================================

To use this, enter a formula in the form of:

=NWD(StartDt,EndDt,[Holidays])

StartDt can be a discontiguous range, as can EndDt. They could also be named
ranges. Holidays is an optional range.

Example:

=NWD((A1,D1,G1),(B1,E1,H1))

or =NWD(StartDt, EndDt, Holidays)

where

StartDt Refers To: A1,D1,G1

etc.
--ron
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
NETWORKDAYS calc with 3 columns of dates Mendz5 Excel Worksheet Functions 26 August 18th 06 09:21 PM
How do I select the nearest date from a ranges of dates? gerrit Excel Discussion (Misc queries) 3 February 12th 06 04:45 PM
How do I chart date ranges with varying start and finish dates? projectplanner Charts and Charting in Excel 4 May 1st 05 11:36 PM
How do I count cells in a column of dates between date ranges? Andrew82 Excel Worksheet Functions 2 April 14th 05 09:59 AM
Calculating days between current date and a date in future NETWORKDAYS() function Faheem Khan Excel Worksheet Functions 2 February 10th 05 07:18 PM


All times are GMT +1. The time now is 09:12 AM.

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

About Us

"It's about Microsoft Excel"