+ Reply to Thread
Results 1 to 5 of 5

Counting the instances of months in a range of dates

  1. #1
    Registered User
    Join Date
    12-24-2011
    Location
    Utah
    MS-Off Ver
    Excel 2003
    Posts
    2

    Counting the instances of months in a range of dates

    I have a column of dates formatted mm/dd/yyyy on one sheet. On a second sheet in the workbook I am trying to keep a running count of the number of times January, February, March, etc... are entered. I have this below and it seems to work except for January. I get a count of 751, all of the blank cells. If I type a date in January 751 reduces to 750. For February, March, etc. it works fine.

    =SUMPRODUCT(--(MONTH(INDIRECT(AB18))=1))

    AB18 is Papers!$C$4250:$C$5000 for the other sheet and cell range.

    Thanks for any help!
    Last edited by montek; 12-25-2011 at 12:12 PM. Reason: Problem Solved

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Counting the instances of months in a range of dates

    Try this array formula, copied down twelve rows.

    {=COUNT(IF(MONTH(Sheet1!$A$1:$A$37)=ROW(A1),Sheet1!$A$1:$A$37))}

    Adjust the cell references in the formula for the cells containing the dates.

    Array formulas are committed using the Ctrl + Shift + Enter keys in combination.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Counting the instances of months in a range of dates

    Try like this,

    =SUMPRODUCT(--(TEXT(INDIRECT(AB18),"mmm;;")="Jan"))

    If you need to use full month like, "January", "March", "July" etc.. use 4 mmmm
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Counting the instances of months in a range of dates

    Quote Originally Posted by montek View Post
    ...it seems to work except for January. I get a count of 751, all of the blank cells. If I type a date in January 751 reduces to 750. For February, March, etc. it works fine.
    To explain the results you're seeing with your original

    In XL Dates are Serial Numbers
    In XL true Blanks equate to 0
    On 1900 Date System 0 in Date Terms equates to 0 Jan 1900

    Hence when you test the Month of a blank it will be 1 (January)

    Haseeb's approach circumvents the above by virtue of a Custom Format (0's are handled such that they do not return Jan) ... avoiding use of explicit coercion is also no bad thing IMO (eg TEXT vs MONTH)

  5. #5
    Registered User
    Join Date
    12-24-2011
    Location
    Utah
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Counting the instances of months in a range of dates

    Thanks to all who replied. I tried the text function, but I didn't use the "mmm", adding that, it works perfectly.

    I racked my brain (what little there is) for quite a while and I couldn't figure out why it was counting the blank cells, thanks for explaining that one.

    This problem is solved. Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1