View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default How to list dates in a month of particular weekday

On Sat, 23 Jan 2010 08:28:01 -0800, MasterDragon
wrote:

MY question is simple, sorry if i'm being stupid.

Can anyone tell me how can i make a list which contains only dates of all
the Fridays in a particular month?

In a more advanced sense, can I create a list with all the Fridays AND
Saturdays of a month?


With some date in the month of interest in A1

First Friday of the month:

=A1-DAY(A1)+8-WEEKDAY(A1-DAY(A1)+2)

Or, to generalize:

=A1-DAY(A1)+8-WEEKDAY(A1-DAY(A1)+8-DOW)

Where DOW = Day of Week (Sun = 1)

So the first Saturday would be:

=A1-DAY(A1)+8-WEEKDAY(A1-DAY(A1)+1)

So, to get all the Fridays in a given month, again with some date in that month
in A1:

B1:

=IF(MONTH($A$1-DAY($A$1)+8-WEEKDAY($A$1-DAY($A$1)+2)+
(ROWS($1:1)-1)*7)<MONTH($A$1),"",$A$1-DAY($A$1)+8-
WEEKDAY($A$1-DAY($A$1)+2)+(ROWS($1:1)-1)*7)

This tests to make sure the month output is the same as the month of A1.

The same, obviously, would apply for Saturdays.
--ron