What counts in Excel




Hi and congratulations on an excellent magazine. I hope you can help me. I have a spreadsheet with data in cells in the range A1..F20. The numbers (in the cells) range from 1 to 40. This range will become larger as new data is added.
What I need to do is enter a range of formulae to return the number of entries of certain numbers within the range and to show the result in another cell.
- Brian Jefford


You can do it easily in Excel v6 or 7. First, name the range of numbers you want to count. Just select the range, click the name box at the left end of the formula bar, and type the name you want, say "Numbers".
Let's say your Numbers range starts at A1. In cell B1, just beside the first of your numbers, type the formula:
=CountIf(Numbers, A1)
Just type =CountIf(Numbers then click cell A1 and press Enter. Now copy the contents of cell B1 to the entire B column. Lo, each entry in column B contains the number of cells in column A matching the value to its left.
To sort the records, select both column A and column B, then Choose Data-Sort. Sort on Column A. To sort in order of frequency of number occurrence, sort on column B.
If you want to filter so you only see unique entries, choose Data-Filter--Advanced Filter and check the Unique Records Only option.
Is this what you had in mind?
It must have been: Brian Jefford replied:

Thank you for your help with my spreadsheet problem, your solution was excellent. With a little adjustment I was able to use the formula to give me occurrence of certain numbers in a range spread over six columns. By naming a range larger than required at present I am able to add new data and the results are updated automatically.
Your Help Screen is invaluable to people like me. Please keep up the good work.

Thanks for letting me know it worked. It's worth mentioning that you don't have to make the range larger than required. If you insert rows before the end of a named range, the range extends.
- Neale Morison


Category: Spreadsheet
Issue: Oct 1996
Pages: 168-170

These Web pages are produced by Australian PC World © 1997 IDG Communications