+ Reply to Thread
Results 1 to 7 of 7

COUNTIF and range?

  1. #1
    Hardy
    Guest

    COUNTIF and range?

    I would like to count how many values there are between a certain range.

    E.g.

    In column B I have the age of individuals. I would like to count the number
    of individuals that are between the age of 18 - 30
    Can anyone help?

    Also is there a simple formula for the calculation of age?

  2. #2
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    There is a formula that can be used and it is called sumproduct.

    Example: =SUMPRODUCT((B1:B50>=18)*(B1:B50<=30))

    Each row will be tested
    (True)*(True)-->1
    (False)*(True) -->0
    and all test will then be summarised, giving you the number persons between 18 and 30.

    Hope it helped
    Ola Sandström



    Note
    If you for some reason want to calculate the average age, this is one way
    =SUMPRODUCT((B1:B50>=18)*(B1:B50<=30)*(B1:B50))/SUMPRODUCT((B1:B50>=18)*(B1:B50<=30))
    Last edited by olasa; 07-22-2005 at 10:04 AM.

  3. #3
    Poody
    Guest

    RE: COUNTIF and range?

    I don't know that this is simple, but here is one way of doing it:

    =COUNT(A1:A10)-COUNTIF(A1:A10,"<30")-COUNTIF(A1:A10,">39")

    I had a list of numbers in Column A (rows 1 - 10), and I decided I would
    look for ages 30 - 39.

    The COUNTA part of the formula gives the count of values in that range, I
    then subtracted out the values that were less than 30 or greater than 39 with
    the countif statements.

    There might be a better way of doing that, but I hope this helps.

    Rich

    "Hardy" wrote:

    > I would like to count how many values there are between a certain range.
    >
    > E.g.
    >
    > In column B I have the age of individuals. I would like to count the number
    > of individuals that are between the age of 18 - 30
    > Can anyone help?
    >
    > Also is there a simple formula for the calculation of age?


  4. #4
    KL
    Guest

    Re: COUNTIF and range?

    Hi Hardy,

    Try one of this:

    =COUNTIF(B:B,"<=30")-COUNTIF(B:B,"<18")

    =SUMPRODUCT((B1:B100>=18)*(B1:B100<=30))

    Regards,
    KL


    "Hardy" <[email protected]> wrote in message
    news:[email protected]...
    >I would like to count how many values there are between a certain range.
    >
    > E.g.
    >
    > In column B I have the age of individuals. I would like to count the
    > number
    > of individuals that are between the age of 18 - 30
    > Can anyone help?
    >
    > Also is there a simple formula for the calculation of age?




  5. #5
    Hardy
    Guest

    RE: COUNTIF and range?

    Thanks thats really useful

    Just to let you know the first part "COUNT(A1:A10)-" is not needed for the
    formula to work.
    Thanks again



    "Poody" wrote:

    > I don't know that this is simple, but here is one way of doing it:
    >
    > =COUNT(A1:A10)-COUNTIF(A1:A10,"<30")-COUNTIF(A1:A10,">39")
    >
    > I had a list of numbers in Column A (rows 1 - 10), and I decided I would
    > look for ages 30 - 39.
    >
    > The COUNTA part of the formula gives the count of values in that range, I
    > then subtracted out the values that were less than 30 or greater than 39 with
    > the countif statements.
    >
    > There might be a better way of doing that, but I hope this helps.
    >
    > Rich
    >
    > "Hardy" wrote:
    >
    > > I would like to count how many values there are between a certain range.
    > >
    > > E.g.
    > >
    > > In column B I have the age of individuals. I would like to count the number
    > > of individuals that are between the age of 18 - 30
    > > Can anyone help?
    > >
    > > Also is there a simple formula for the calculation of age?


  6. #6
    Sanford Lefkowitz
    Guest

    Re: COUNTIF and range?

    I think the formula also works using just SUM (instead of SUMPRODUCT)

    "olasa" wrote:

    >
    > There is a formula that can be used and it is called sumproduct.
    >
    > Example: =SUMPRODUCT((B1:B50>=18)*(B1:B50<=30))
    >
    > Each row will be tested
    > (True)*(True)-->1
    > (False)*(True) -->0
    > and all test will then be summarised, giving you the number persons
    > between 18 and 30.
    >
    > Hope it helped
    > Ola Sandström
    >
    >
    >
    > Note
    > If you for some reason want to calculate the average age, this is one
    > way
    > =SUMPRODUCT((B1:B50>=18)*(B1:B50<=30)*(B1:B50))/SUMPRODUCT((B1:B50>=18)*(B1:B50<=30))
    >
    >
    > --
    > olasa
    > ------------------------------------------------------------------------
    > olasa's Profile: http://www.excelforum.com/member.php...o&userid=17760
    > View this thread: http://www.excelforum.com/showthread...hreadid=389344
    >
    >


  7. #7
    KL
    Guest

    Re: COUNTIF and range?

    only if array-entered (Ctrl+Shift+Enter)

    KL


    "Sanford Lefkowitz" <[email protected]> wrote in
    message news:[email protected]...
    >I think the formula also works using just SUM (instead of SUMPRODUCT)
    >
    > "olasa" wrote:
    >
    >>
    >> There is a formula that can be used and it is called sumproduct.
    >>
    >> Example: =SUMPRODUCT((B1:B50>=18)*(B1:B50<=30))
    >>
    >> Each row will be tested
    >> (True)*(True)-->1
    >> (False)*(True) -->0
    >> and all test will then be summarised, giving you the number persons
    >> between 18 and 30.
    >>
    >> Hope it helped
    >> Ola Sandstrom
    >>
    >>
    >>
    >> Note
    >> If you for some reason want to calculate the average age, this is one
    >> way
    >> =SUMPRODUCT((B1:B50>=18)*(B1:B50<=30)*(B1:B50))/SUMPRODUCT((B1:B50>=18)*(B1:B50<=30))
    >>
    >>
    >> --
    >> olasa
    >> ------------------------------------------------------------------------
    >> olasa's Profile:
    >> http://www.excelforum.com/member.php...o&userid=17760
    >> View this thread:
    >> http://www.excelforum.com/showthread...hreadid=389344
    >>
    >>




+ 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