+ Reply to Thread
Results 1 to 5 of 5

Counting Values Based on Criteria

  1. #1
    Registered User
    Join Date
    03-10-2008
    Posts
    21

    Counting Values Based on Criteria

    I am trying to count the number of Ys by month below. So I need to track how many Ys for Jan, Feb, Mar and so on...
    I am looking for a formula that will count them based on the date criteria and will automatically update each time new data is entered.

    Date Y/N
    1/1/2008 N
    1/5/2008 N
    1/5/2008 N
    1/15/2008 Y
    1/17/2008 Y
    1/17/2008 N
    1/25/2008 Y
    1/29/2008 N
    2/2/2008 N
    2/5/2008 N
    2/14/2008 Y
    3/1/2008 N
    3/6/2008 Y
    3/14/2008 N

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try a pivot table.

    Make it dynamic (see link)

    http://www.contextures.com/xlPivot01.html

    Or a formula Drag down to change months

    =SUMPRODUCT((MONTH($A$1:$A$1000)=ROW(A1))*($B$1:$B$1000="Y"))
    and

    =SUMPRODUCT((MONTH($A$1:$A$1000)=ROW(B1))*($B$1:$B$1000="N"))
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Example of both attached

    VBA Noob
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    03-10-2008
    Posts
    21
    Thanks for your help VBA Noob. I have two more questions. On the Pivot Table, how did you get the "date" to display the Month as opposed to the exact date?
    Also, on the solution, how do I chang the Month Formula to recognize the year as well, in case this spreadsheet is used through 2009? Thanks!

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    For the formula try

    =SUMPRODUCT(--(TEXT($A$2:$A$1001,"MM/YY")="01/09")*($B$2:$B$1001="Y"))
    Or use this to avoid changing the months

    =SUMPRODUCT(--(TEXT($A$2:$A$1001,"MM/YY")="0"&ROW(A1)&"/09")*($B$2:$B$1001="Y"))
    and link explains the groupling by months

    http://www.contextures.com/xlPivot07.html#Dates

    VBA Noob
    Last edited by VBA Noob; 03-10-2008 at 05:58 PM.

+ 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