Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 68
Default Counting Mondays in Date Range

I want to count the number of Mondays etc. in a date range. I found the
following on Chip Pearson's site...

=SUM(IF(WEEKDAY(A2-1+ROW(INDIRECT("1:"&TRUNC(B2-A2)+1)))=C2,1,0))

Where A2 is the start date, B2 is the end and C2 is the weekday number

Whilst this does the trick I would prefer a solution which is not an array
formula. Can this be done another way e.g. with Sumproduct or similar and if
so how please?

Thanks a lot

Kewa


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,836
Default Counting Mondays in Date Range

Here is one way of doing it:
=SUMPRODUCT(--(WEEKDAY(ROW(INDIRECT(A1&":"&A29)),2)={2}))
A1 = the cell with the first date
A29 = the cell with the last date
Change to suit your needs...

Regards,
Ryan---

--
RyGuy


"nospaminlich" wrote:

I want to count the number of Mondays etc. in a date range. I found the
following on Chip Pearson's site...

=SUM(IF(WEEKDAY(A2-1+ROW(INDIRECT("1:"&TRUNC(B2-A2)+1)))=C2,1,0))

Where A2 is the start date, B2 is the end and C2 is the weekday number

Whilst this does the trick I would prefer a solution which is not an array
formula. Can this be done another way e.g. with Sumproduct or similar and if
so how please?

Thanks a lot

Kewa


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Counting Mondays in Date Range

On Thu, 28 Feb 2008 08:16:03 -0800, nospaminlich
wrote:

I want to count the number of Mondays etc. in a date range. I found the
following on Chip Pearson's site...

=SUM(IF(WEEKDAY(A2-1+ROW(INDIRECT("1:"&TRUNC(B2-A2)+1)))=C2,1,0))

Where A2 is the start date, B2 is the end and C2 is the weekday number

Whilst this does the trick I would prefer a solution which is not an array
formula. Can this be done another way e.g. with Sumproduct or similar and if
so how please?

Thanks a lot

Kewa



The number of DOW (1= Sunday, 2 = Monday, ..., 7 = Saturday) between a start
date (A1) and an end date (A2) is :

=INT((A2-WEEKDAY(A2+1-DOW)-A1+8)/7)

(credit to Daniel M.)
--ron
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,856
Default Counting Mondays in Date Range

You asked specifically for Mondays within a date range, so I'm not
sure why you need column C. Here's one way of doing it:

=INT((B2-A2)/7)+IF(MOD(B2-A2,7)+WEEKDAY(A2,2)7,1,0)

This assumes the dates are inclusive.

Hope this helps.

Pete

On Feb 28, 4:16*pm, nospaminlich
wrote:
I want to count the number of Mondays etc. in a date range. *I found the
following on Chip Pearson's site...

=SUM(IF(WEEKDAY(A2-1+ROW(INDIRECT("1:"&TRUNC(B2-A2)+1)))=C2,1,0))

Where A2 is the start date, B2 is the end and C2 is the weekday number

Whilst this does the trick I would prefer a solution which is not an array
formula. *Can this be done another way e.g. with Sumproduct or similar and if
so how please?

Thanks a lot

Kewa


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 68
Default Counting Mondays in Date Range

Thanks a lot for the very helpful replies.


  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,836
Default Counting Mondays in Date Range

I just noticed a little tiny issue with my function if the last date is a
Monday. Try this:
=SUMPRODUCT(--(WEEKDAY(ROW(INDIRECT(A1&":"&A26)),1)={2}))
I changed the second to last 2 to a one and it seemed to work...

Regards,
Ryan--

--
RyGuy


"nospaminlich" wrote:

Thanks a lot for the very helpful replies.

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
Counting Within a Date Range Tracey Excel Worksheet Functions 2 October 27th 07 01:59 PM
Counting a range to see if it encompasses a given date Quovardis Excel Worksheet Functions 6 October 11th 07 01:46 PM
Counting Unique Values by Date Range [email protected] Excel Worksheet Functions 5 August 2nd 07 09:36 PM
Counting if between date range Marc Shaw Excel Worksheet Functions 7 September 25th 06 07:26 PM
Counting values within a Date Range Jana Excel Discussion (Misc queries) 7 December 9th 04 10:18 PM


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