Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 54
Default weekdays not using NETWORKDAYS

I have a spreadsheet that various different users have access to. I can't use
the "NETWORKDAYS" function because not everyone has that add-in loaded. How
can I calculate the number of workdays in a month? I have the beginning date
and end date of the month, I just need to calculate the number of workdays
between the two dates.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 244
Default weekdays not using NETWORKDAYS

On Jun 25, 4:03*pm, ChrisP wrote:
I have a spreadsheet that various different users have access to. I can't use
the "NETWORKDAYS" function because not everyone has that add-in loaded. How
can I calculate the number of workdays in a month? I have the beginning date
and end date of the month, I just need to calculate the number of workdays
between the two dates.

Thanks.


see this google search for some ideas

http://www.google.co.uk/search?sourc...+days+in+excel
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default weekdays not using NETWORKDAYS

=SUMPRODUCT(INT((MAX(end_date,start_date)-WEEKDAY(MAX(end_date,start_date)+1-{2;3;4;5;6})-MIN(end_date,start_date)+8)/7))

or with a holiday list

=SUMPRODUCT(INT((MAX(end_date,start_date)-WEEKDAY(MAX(end_date,start_date)+1-{2;3;4;5;6})-MIN(end_date,start_date)+8)/7))
-SUMPRODUCT(ISNUMBER(MATCH(WEEKDAY(holidays),{2;3;4 ;5;6},0))*(holidays=MIN(end_date,start_date))*(ho lidays<=MAX(end_date,start_date)))

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"ChrisP" wrote in message
...
I have a spreadsheet that various different users have access to. I can't
use
the "NETWORKDAYS" function because not everyone has that add-in loaded.
How
can I calculate the number of workdays in a month? I have the beginning
date
and end date of the month, I just need to calculate the number of workdays
between the two dates.

Thanks.



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default weekdays not using NETWORKDAYS

Here is a function I've posted in the past (over in the compiled VB
newsgroups) that will return the number of non-weekend days between two
given dates...

Function WorkDays(StartDate As Date, EndDate As Date) As Long
Dim D As Date
Dim NumWeeks As Long
NumWeeks = (EndDate - StartDate) \ 7
WorkDays = NumWeeks * 5
For D = (StartDate + NumWeeks * 7) To EndDate
If (Weekday(D) Mod 6) < 1 Then WorkDays = WorkDays + 1
Next
End Function

Note that it only works for Saturday and Sunday as the weekend and it has no
provision to account for holidays. I thought I had a routine that did
account for holidays, but I cannot find it in my personal archives at the
moment (if I do find it, I'll post it, so you may want to check back later
in the day).

Rick


"ChrisP" wrote in message
...
I have a spreadsheet that various different users have access to. I can't
use
the "NETWORKDAYS" function because not everyone has that add-in loaded.
How
can I calculate the number of workdays in a month? I have the beginning
date
and end date of the month, I just need to calculate the number of workdays
between the two dates.

Thanks.


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default weekdays not using NETWORKDAYS

Hmm! I thought I was in the programming newsgroup when I answered your
question. When I came back to this thread and saw Bob's answer, I realized I
had been mistaken. Sorry if that caused any confusing for you.

In any event, if you are up for a User Defined Function (UDF), the function
I posted, when placed in a VBA Module, can be used from the worksheet and it
will work the same as a built-in function does. If you want to explore this
method but are unfamiliar with UDFs, here are the details on how to
implement it. Press Alt+F11 to get into the VBA editor; click Insert/Module
from its menu bar to open up the code window for a Module; and copy/paste
the WorkDays function (that I posted in my first response) into the code
window that appeared. Now, go back to the worksheet and put this in a cell..

=WorkDays(A1,A2)

where A1 is the start date and A2 is the end date... the formula will
display the number of non-weekend days between (and including) those dates.

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Here is a function I've posted in the past (over in the compiled VB
newsgroups) that will return the number of non-weekend days between two
given dates...

Function WorkDays(StartDate As Date, EndDate As Date) As Long
Dim D As Date
Dim NumWeeks As Long
NumWeeks = (EndDate - StartDate) \ 7
WorkDays = NumWeeks * 5
For D = (StartDate + NumWeeks * 7) To EndDate
If (Weekday(D) Mod 6) < 1 Then WorkDays = WorkDays + 1
Next
End Function

Note that it only works for Saturday and Sunday as the weekend and it has
no provision to account for holidays. I thought I had a routine that did
account for holidays, but I cannot find it in my personal archives at the
moment (if I do find it, I'll post it, so you may want to check back later
in the day).

Rick


"ChrisP" wrote in message
...
I have a spreadsheet that various different users have access to. I can't
use
the "NETWORKDAYS" function because not everyone has that add-in loaded.
How
can I calculate the number of workdays in a month? I have the beginning
date
and end date of the month, I just need to calculate the number of
workdays
between the two dates.

Thanks.





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default weekdays not using NETWORKDAYS

I would post a function in programming and VBA in worksheetfunctions if I
thought it best Rick <bg

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Rick Rothstein (MVP - VB)" wrote in
message ...
Hmm! I thought I was in the programming newsgroup when I answered your
question. When I came back to this thread and saw Bob's answer, I realized
I had been mistaken. Sorry if that caused any confusing for you.

In any event, if you are up for a User Defined Function (UDF), the
function I posted, when placed in a VBA Module, can be used from the
worksheet and it will work the same as a built-in function does. If you
want to explore this method but are unfamiliar with UDFs, here are the
details on how to implement it. Press Alt+F11 to get into the VBA editor;
click Insert/Module from its menu bar to open up the code window for a
Module; and copy/paste the WorkDays function (that I posted in my first
response) into the code window that appeared. Now, go back to the
worksheet and put this in a cell..

=WorkDays(A1,A2)

where A1 is the start date and A2 is the end date... the formula will
display the number of non-weekend days between (and including) those
dates.

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Here is a function I've posted in the past (over in the compiled VB
newsgroups) that will return the number of non-weekend days between two
given dates...

Function WorkDays(StartDate As Date, EndDate As Date) As Long
Dim D As Date
Dim NumWeeks As Long
NumWeeks = (EndDate - StartDate) \ 7
WorkDays = NumWeeks * 5
For D = (StartDate + NumWeeks * 7) To EndDate
If (Weekday(D) Mod 6) < 1 Then WorkDays = WorkDays + 1
Next
End Function

Note that it only works for Saturday and Sunday as the weekend and it has
no provision to account for holidays. I thought I had a routine that did
account for holidays, but I cannot find it in my personal archives at the
moment (if I do find it, I'll post it, so you may want to check back
later in the day).

Rick


"ChrisP" wrote in message
...
I have a spreadsheet that various different users have access to. I can't
use
the "NETWORKDAYS" function because not everyone has that add-in loaded.
How
can I calculate the number of workdays in a month? I have the beginning
date
and end date of the month, I just need to calculate the number of
workdays
between the two dates.

Thanks.





  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default weekdays not using NETWORKDAYS

Of course, and I have done that myself on occasion; however, for the OP's
question, I wasn't sure if the function solution was best or not (and, of
course, I originally envisioned it being called by other VB code when I
constructed it being that I thought I was in the programming newsgroup). As
a UDF, the routine is quick as far as the VB code goes, but that is
counteracted by the loss in running VB code at the worksheet level. True,
the SUMPRODUCT function is not a speed demon among the various worksheet
functions, but it is my understanding that even slow worksheet functions
have the speed advantage over even the quickest of UDFs.

Rick


"Bob Phillips" wrote in message
...
I would post a function in programming and VBA in worksheetfunctions if I
thought it best Rick <bg

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Rick Rothstein (MVP - VB)" wrote in
message ...
Hmm! I thought I was in the programming newsgroup when I answered your
question. When I came back to this thread and saw Bob's answer, I
realized I had been mistaken. Sorry if that caused any confusing for you.

In any event, if you are up for a User Defined Function (UDF), the
function I posted, when placed in a VBA Module, can be used from the
worksheet and it will work the same as a built-in function does. If you
want to explore this method but are unfamiliar with UDFs, here are the
details on how to implement it. Press Alt+F11 to get into the VBA editor;
click Insert/Module from its menu bar to open up the code window for a
Module; and copy/paste the WorkDays function (that I posted in my first
response) into the code window that appeared. Now, go back to the
worksheet and put this in a cell..

=WorkDays(A1,A2)

where A1 is the start date and A2 is the end date... the formula will
display the number of non-weekend days between (and including) those
dates.

Rick


"Rick Rothstein (MVP - VB)" wrote
in message ...
Here is a function I've posted in the past (over in the compiled VB
newsgroups) that will return the number of non-weekend days between two
given dates...

Function WorkDays(StartDate As Date, EndDate As Date) As Long
Dim D As Date
Dim NumWeeks As Long
NumWeeks = (EndDate - StartDate) \ 7
WorkDays = NumWeeks * 5
For D = (StartDate + NumWeeks * 7) To EndDate
If (Weekday(D) Mod 6) < 1 Then WorkDays = WorkDays + 1
Next
End Function

Note that it only works for Saturday and Sunday as the weekend and it
has no provision to account for holidays. I thought I had a routine that
did account for holidays, but I cannot find it in my personal archives
at the moment (if I do find it, I'll post it, so you may want to check
back later in the day).

Rick


"ChrisP" wrote in message
...
I have a spreadsheet that various different users have access to. I
can't use
the "NETWORKDAYS" function because not everyone has that add-in loaded.
How
can I calculate the number of workdays in a month? I have the beginning
date
and end date of the month, I just need to calculate the number of
workdays
between the two dates.

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
Idenfying WeekDays carl Excel Worksheet Functions 4 December 17th 07 08:28 PM
Weekdays only! rexmann Excel Discussion (Misc queries) 2 August 14th 07 02:52 PM
WEEKENDS VS. WEEKDAYS TLAngelo Excel Discussion (Misc queries) 7 May 12th 06 05:31 PM
Weekdays only on X axis NNester Charts and Charting in Excel 3 April 25th 05 04:53 PM
Weekdays Jeff Excel Discussion (Misc queries) 7 February 15th 05 12:18 AM


All times are GMT +1. The time now is 08:37 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"