Consulting

Results 1 to 6 of 6

Thread: Solved: Formula for count if between two dates

  1. #1
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location

    Solved: Formula for count if between two dates

    All

    can anyone help with the following,

    I have a row containing peoples age (e.g. 60), i need to add one to the total in my cell if the age is between 55 and 65, can anyone help with this please, i ve tried countif but i think that can only have one criteria?

    thanks

    gibbo

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this:

    =SUMPRODUCT(--(A1:A5>=55),--(A1:A5<=65))

    This will count exactly 55 and 65 as well. If you just want inbetween those:

    =SUMPRODUCT(--(A1:A5>55),--(A1:A5<65))

    Change the A1:A5 to your range. Just note that you cannot use the whole column (i.e. A:A).

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    =COUNTIF(1:1,">=55")-COUNTIF(1:1,">65")

  4. #4
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location
    Thanks both but neither work for me, I have just realised i should have added something

    I am using a formula to work out the age from a date

    =IF(D5<>"",DATEDIF(D5,NOW(),"y"),"")

    This is the cell I am trying to get the data from, will the fact I have a formula in there make a difference?

    thanks

    Gibbo

  5. #5
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    gibbo

    I don't see why the value being the result of a formula would cause a problem.

    Can you attach a sample workbook?

  6. #6
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location
    Sorry, my mistake, now i ve revisited this it works great

    thanks again

    Gibbo

Posting Permissions

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