+ Reply to Thread
Results 1 to 5 of 5

Count if in a range by year

  1. #1
    Registered User
    Join Date
    07-11-2012
    Location
    Washington, D.C.
    MS-Off Ver
    Excel 2007
    Posts
    5

    Count if in a range by year

    I am trying to develop a length frequency table to graph. I am trying to count the number of data cells that fall within a length range for each year.The formula below is what I tried as an example, but encountered an error. D4:D18 are the cells with the length data (16-24), B4:B18 are the corresponding year cells (1980-1985) and K4 is the cell with the particular year (1980) in the length frequency table. Can anyone help with this error?

    =COUNTIF(D4:D18,">=16.0"and(B4:B18=K4)) - COUNTIF(D4:D18,">18.0"and(B4:B18=K4))

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Count if in a range by year

    You can't just slip the word "and" into the middle of a COUNTIF. If you have more than one criteria... use COUNTIFS().

    =COUNTIFS(D4:D18, ">=16.0", D4:D18, "<18.0", B4:B16, K4)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,447

    Re: Count if in a range by year

    Try
    Please Login or Register  to view this content.

  4. #4
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Count if in a range by year

    =COUNTIFS(d4:d18, ">=16", b4:b18, =k4) - COUNTIFS(d4:d18, ">18", b4:b18, =k4)

  5. #5
    Registered User
    Join Date
    07-11-2012
    Location
    Washington, D.C.
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Count if in a range by year

    Quote Originally Posted by JBeaucaire View Post
    You can't just slip the word "and" into the middle of a COUNTIF. If you have more than one criteria... use COUNTIFS().

    =COUNTIFS(D4:D18, ">=16.0", D4:D18, "<18.0", B4:B16, K4)
    Thanks for the help, this worked perfectly.

+ 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