COUNTIFS between two values

1 / 5

Count the customers in each age band. Each band has its own limits: from E2 to F2 for the first.

keyboard Typing formulas is easiest on a computer with a keyboard.

A1
ABCDEFGH
1CustomerAgeBandFromToCustomers
2Yusuf4818 to 291829
3Uma3730 to 443044
4Felix5945 to 594559
5Rosa4660+6099
6Hiro67
7Amara85
8Jamal45
9Quinn59
10Priya51
11Ben44
12Isla83
13Chloe18
14
15
16
17
ages
counts
Type to enter a value or a formula starting with =. F2 edits, F4 adds $ to a reference.
Study notes

How COUNTIFS works

  • How do you count between two values?

    Give COUNTIFS the same range twice: once with a lower limit and once with an upper limit. It only counts the cells that pass both.

    =COUNTIFS(B2:B13,">=30",B2:B13,"<=44")

  • How do you take the limits from cells?

    Join the operator to the cell with &, as in the criteria lesson:

    =COUNTIFS($B$2:$B$13,">="&E2,$B$2:$B$13,"<="&F2)

    Now each row of a band table can have its own limits, and one formula copied down counts every band.

  • Should it be >= or >?

    Decide which band an edge value belongs to. With ">=" and "<=", someone aged exactly 30 is counted in the 30 to 44 band. Use ">=" for the lower limit and "<" for the next band's start if your limits touch, such as 0 to 10, 10 to 20.

  • Does this work with dates?

    Yes. Dates are numbers in Excel, so ">="&E2 with a date in E2 counts everything on or after it. That is how you count orders in a month.

Know someone fighting with a spreadsheet? Send them this page.