Find the Months that have 5 Fridays in them

Stephen_IV

Well-known Member
Joined
Mar 17, 2003
Messages
1,180
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I would like to be able to put the year in A1 and have in column B the months that have 5 Fridays in them. For instance if I put 2010 in A1, I would like in Column B January, April, July,October, December to appear. Any help would be appreciated if I put 2005 in A1 then I would like April, July, September, December. Thanks in advance Stephen.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Here's a start...not QUITE what your asking for, but should get you going..

if A1 = year
in B1 and filled down to B12

=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))

This will give you the count of fridays in each month.
Row 1 = Jan
Row 2 = Feb
etc..

Hope that helps..
 
Last edited:
Upvote 0
Another not quite what was asked for.
Put a year in A1

In B1, put =TEXT(DATE($A$1,ROW(),1),"mmmm")

and in C1=(MONTH(DATE($A$1,ROW(),29)+MOD(6-WEEKDAY(DATE($A$1,ROW(),29)),7)) = ROW())

Drag B1:C1 down to B12:C12
then column C will tell you if there are 5 Fridays in the month shown in column B.

(Filtering column C for TRUE?)
 
Upvote 0
OK, here's a complete solution.
It does require 2 formulas...

The first formula is pretty much the same as the one I posted before, but made more robust. The last one I posted would only work if it was placed in Row 1 and filled down. It would not have worked if you put it in any other row. That is resolved now. So it looks alot longer. Plus it adds a decimal number to the count, so each 5 will be unique and can be ranked..


A1 = Year
B1 =
=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROWS($A$1:$A1),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROWS($A$1:$A1)+1,0))))))=6))+(0.01*ROWS($A$1:$A1))
C1 =
=IF(ISNUMBER(SMALL(IF($B$1:$B$12>=5,$B$1:$B$12),ROWS($A$1:$A1))),TEXT(DATE($A$1,MATCH(SMALL(IF($B$1:$B$12>=5,$B$1:$B$12),ROWS($A$1:$A1)),$B$1:$B$12,0),1),"mmmm"),"")

The formula in C1 is an Array formula that requires CTRL + SHIFT + ENTER
After entering the formula in C1, highlight the cell and press F2
Then press CTRL + SHIFT + ENTER
When entered correctly, the formula will be enclosed in {Brackets}

Again, you can put them anywhere you want, but in the 2nd formula, $B$1:$B$12 refers to the range you put the first formula in.
 
Last edited:
Upvote 0
Here' still another... I took Jonmo1's (#3) recommendation filling Col B (B1:B12) and
created a UDF for Cell C1 -- =FridaysIn(B1:B12) -- So here you are...

The UDF (Paste into a Standard module) is:

Code:
Function FridaysIn(Rng As Range) As String
Set Rng = Rng
Flag = 0
For i = 1 To 12
    If Flag = 0 Then
    If Cells(i, 2).Value = 5 Then
    T = WorksheetFunction.Choose(i, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jly", "Aug", "Sep", "Oct", "Nov", "Dec") & ", "
    Flag = Flag + 1
    End If
        Else
    If Cells(i, 2).Value = 5 Then T = T & WorksheetFunction.Choose(i, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jly", "Aug", "Sep", "Oct", "Nov", "Dec") & ", "
    End If
Next i
FridaysIn = T
End Function
Excel Workbook
ABC
120105Jan, Apr, Jly, Oct, Dec,
24
34
45
54
64
75
84
94
105
114
125
Sheet1
Excel 2003
Cell Formulas
RangeFormula
B1=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))
B2=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))
B3=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))
B4=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))
B5=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))
B6=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))
B7=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))
B8=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))
B9=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))
B10=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))
B11=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))
B12=SUMPRODUCT(--(WEEKDAY(DATE($A$1,ROW(),ROW($A$1:INDEX(A:A,DAY(DATE($A$1,ROW()+1,0))))))=6))
C1=FridaysIn(B1:B12)
 
Upvote 0
WOW, looking back on this -- Although it works.. it is a programming disaster.. I've broken most rules of programming. Need I say more? It could be cleaned up and later have a bit more merit, but not till then.
Jim
 
Upvote 0
Well, if you're going to go UDF, you might as well do the whole thing in the UDF, and not depend on the helper column B

This uses the formula in the thread suggested by TexasaLynn
http://www.mrexcel.com/forum/showthread.php?t=375105

Code:
Function fivefridaymonths(yr As Long)
For mnth = 1 To 12
    x = 4 - (Day(DateSerial(yr, mnth, 1) + 34) < Application.Weekday(DateSerial(yr, mnth, 1) - 6))
    If x = 5 Then mystring = mystring & Format(DateSerial(yr, mnth, 1), "mmm") & ", "
Next mnth
fivefridaymonths = Left(mystring, Len(mystring) - 2)
End Function

Then you just use
=fivefridaymonths(2009)
returns
Jan, May, Jul, Oct
 
Upvote 0
Thank you all for the time that you put in on this post, jonmo1 that was it and what I was looking for. Still curious though if it can be done within one formula without helper columns.

Thanks Again Everyone
 
Upvote 0
Here's a single formula solution, however they won't be put nicely at the top of the collumn...
If March has 5, it will show up in row 3
If June has 5, it will show up in row 6
etc...

=IF(4+(DAY(DATE($A$1,ROWS($A$1:$A1),1)+34)< WEEKDAY(DATE($A$1,ROWS($A$1:$A1),1)-6))=5,TEXT(DATE($A$1,ROW(),1),"mmmm"),"")
 
Upvote 0

Forum statistics

Threads
1,225,149
Messages
6,183,193
Members
453,151
Latest member
Lizamaison

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top