Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Pulling All Fridays.

Pulling All Fridays

Written by Allen Wyatt (last updated May 20, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


5

When developing a worksheet to track business information, you may have a need to determine all the Fridays in a range of dates. The best way to do this depends on the data in your worksheet and the way in which you want results displayed.

If you have a list of dates in a column, you can use several different worksheet functions to determine whether those dates are Fridays or not. The WEEKDAY function returns a number, 1 through 7, depending on the weekday of the date used as an argument:

=WEEKDAY(A2)

This usage returns the number 6 if the date in A2 is a Friday. If this formula is copied down next to a column of dates, you could then use the AutoFilter feature of Excel to show only those dates where the weekday is 6 (Friday).

You could also use the conditional formatting feature of Excel to simply highlight all the Fridays in a list of dates. Follow these steps:

  1. Select the list of dates.
  2. Make sure the Home tab of the ribbon is displayed.
  3. Click the Conditional Formatting tool in the Styles group. Excel displays a series of choices.
  4. Click New Rule. Excel displays the New Formatting Rule dialog box. (See Figure 1.)
  5. Figure 1. The New Formatting Rule dialog box.

  6. In the Select a Rule Type area at the top of the dialog box, choose Use a Formula to Determine Which Cells to Format. (See Figure 2.)
  7. Figure 2. Use a Formula to Determine Which Cells to Format.

  8. In the formula area enter the following formula, replacing A2 with the address of the active cell selected in step 1: =WEEKDAY(A2)=6
  9. Click Format to display the Format Cells dialog box.
  10. Set the formatting options to highlight the Fridays as desired.
  11. Click OK to dismiss the Format Cells dialog box.
  12. Click OK.

If you want to determine a series of Fridays based on a beginning and ending date, you can set up a series of formulas to figure them out. Assuming that the beginning date is in A2 and the ending date is in A3, you can use the following formula to figure out the date of the first Friday:

=IF(A2+IF(WEEKDAY(A2)<=6,6-WEEKDAY(A2),6)>A3,
"",A2+IF(WEEKDAY(A2)<=6,6-WEEKDAY(A2),6))

If you place this formula in cell C2 and then format it as a date, you can use the following formula to determine the next Friday in the range:

=IF(C2="","",IF(C2+7>$A$3,"",C2+7))

If you copy this formula down for a bunch of cells, you end up with a list of Fridays between whatever range of dates is specified by A2 and A3.

If you actually want to "pull" Fridays in a specific date range, then you will need to use a macro. There are several ways you can go about this. This simple macro will examine all the dates in the range A2:A24. If they are Fridays, then the date is copied into column C, beginning at C2. The result, of course, is that the list starting at C2 will only contain dates that are Fridays.

Sub PullFridays1()
    Dim dat As Range
    Dim c As Range
    Dim rw As Integer

    Set dat = ActiveSheet.Range("A2:A24")
    rw = 2
    For Each c In dat
        If Weekday(c) = vbFriday Then
            Cells(rw, 3).Value = Format(c)
            rw = rw + 1
        End If
    Next
End Sub

If desired, you can change the range examined by the macro simply by changing the A2:A24 reference, and you can change where the dates are written by changing the value of rw (the row) and the value 3 (the column) in the Cells function.

If you would rather work with a beginning date and an ending date, you can modify the macro so that it will step through the dates. The following macro assumes that the beginning date is in cell A2 and the ending date is in cell A3.

Sub PullFridays2()
    Dim dStart As Date
    Dim dEnd As Date
    Dim rw As Integer

    dStart = Range("A2").Value
    dEnd = Range("A3").Value

    rw = 2
    While dStart < dEnd
        If Weekday(dStart) = vbFriday Then
            Cells(rw, 3).Value = dStart
            Cells(rw, 3).NumberFormat = "m/d/yyyy"
            rw = rw + 1
        End If
        dStart = dStart + 1
    Wend
End Sub

The macro still pulls the Fridays from the range and places them into a list starting at C2.

Another macro approach is to create a user-defined function that returns specific Fridays within a range. The following does just that:

Function PullFridays3(dStartDate As Date, _
                      dEndDate As Date, _
                      iIndex As Integer)
    Dim iMaxDays As Integer
    Dim dFirstday As Date

    Application.Volatile
    If dStartDate > dEndDate Then
        PullFridays3 = CVErr(xlErrNum)
        Exit Function
    End If

    dFirstday = vbFriday - Weekday(dStartDate) + dStartDate
    If dFirstday < dStartDate Then dFirstday = dFirstday + 7
    iMaxDays = Int((dEndDate - dFirstday) / 7) + 1

    PullFridays3 = ""
    If iIndex = 0 Then
        PullFridays3 = iMaxDays
    ElseIf iIndex <= iMaxDays Then
        PullFridays3 = dFirstday + (iIndex - 1) * 7
    End If
End Function

You use this function in a cell in your worksheet in the following manner:

=PULLFRIDAYS3(A2,A3,1)

The first argument for the function is the starting date and the second is the ending date. The third argument indicates which Friday you want returned from within the specified range. If you use 1, you get the first Friday, 2 returns the second Friday, etc. If you use a 0 for the third argument, then the function returns the number of Fridays in the specified range. If the specified beginning date is greater than the ending date, then the function returns a #NUM error.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8147) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Pulling All Fridays.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Combining Numbers and Text in a Cell

There are times when it can be beneficial to combine both numbers and text in the same cell. This can be easily done ...

Discover More

Determining Mouse Cursor Coordinates On a Graphic

Add a graphic to a worksheet as part of an Image object, and you can use some very handy event handlers to figure out the ...

Discover More

Inserting a Cross-Reference to the First Style on a Page

A common way to set up a header is to have it refer to the first occurrence of a heading on the page. (Think how the ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Calculating a Group Retirement Date

Calculating a retirement date can be as simple as doing some date math to see when a person reaches a certain age. ...

Discover More

Calculating Week-Ending Dates

When working with dates, you may need to figure out all the dates on which weeks end in a given year. There are several ...

Discover More

Unique Date Displays

Need to print an elapsed date in a strange format? It's easier to do than may appear at first glance. Here's a discussion ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 5?

2019-04-24 18:23:50

Bhawna Mundotia

For pulling all Fridays, I found this to be much easier:

If you add a date of 5/31/19 in A2, in A3 enter: =A2+7

Source: https://www.cnet.com/forums/discussions/autofill-every-thursday-using-excel-how-do-you-do-it-123572/


2018-12-09 03:21:27

Robert Lohman

Thanks for the tip Peter. I will surely give it a try.


2018-11-24 06:45:27

Peter J Moran

Hi,

Robert,

I have had similar problems looking up earlier articles and had advised Allen of my difficulties.

I now use Google search with the search string preceded by "Excel.Ribbon - " and get very good results.


2018-11-18 00:49:28

Robert

Allen, I have tried to look up the article you had for finding nth weekday of the year but have had no luck. Seems I have a hard time finding any older articles. Is there a trick for searching your past Ribbon tips ? I read all of your tips and appreciate them very much but this one got by me. Please help !


2018-11-17 11:42:20

Rod Grealish

In PullFridays1 I had problems with the display of the pulled dates. Some were displayed as text (left-aligned in cell, not convertible to numbers) and some in US format (mm/dd/yy). My own locale is UK (dd/mm/yy). The pulled dates are placed using Cells(rw, 3).Value = Format(c)

In PullFridays2 pulled dates are placed using
Cells(rw, 3).Value = dStart
Cells(rw, 3).NumberFormat = "m/d/yyyy"

In PullFridays1 I added Cells(rw, 3).NumberFormat = "m/d/yyyy" after Cells(rw, 3).Value = Format(c). This solved the problem, However the dates appeared in dd/mm/yy format.

As an observation on PullFridays2 once the first Friday is found the following Fridays can be determined by adding 7 to dStart until dEnd is exceeded.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.