I have an Excel worksheet with one column of cells with any string values, so, like this: A, B, A, D, C, C, A, A. What I am wanting to do is to count how many times each value occurs and print that out on some other cells, like: A:4, B:1, C:2, D:1. I don't mind if these are spread across 2 columns. I also want to order these, with the most frequent first, like: A:4, C:2, B:1, D:1. How should I go about doing this?

Edit: I also do not know what values will occur.

  • To clarify. Will each cell only have a single value? A or B or C or possibly multiple values in a cell such as A,B,C? Countif will not work for that situation. Also you mention not knowing what values will occur. Do you mean there are other possibilities besides A, B,C,D and your solution needs to allow for a random X or Q etc wwhich may not have been anticipated in advance?
    – datatoo
    Oct 22, 2010 at 16:00

3 Answers 3


You can also use a pivot table for this if you put a title in the cell above your list and then pivot (either in row or column) on your title cell and use count on your title field in the body (data) of the pivot table.

  • @James Wood - you can associate your accounts on superuser and stackoverflow. Not sure about Facebook but I use Google OpenID for mine and it works v well. Excel pivot tables are great, and I'm always learning new things to use them for!
    – Lord Peter
    Oct 23, 2010 at 17:39

In Excel you would use the "countif" function "=countif(A1:A9,"a") where A1:A9 is the range you want to count and "a" is the item you want to count.

You can also use the Insert>Function form the tool bar to insert functions. This will bring up a dialog box so you can pick the function. Once you pick the function, another dialog box will open that will allow you to enter in your parameters. This box will also show the results once the parameters are filled in. There is also a "Help on this Function" link on the bottom of the box.

To sort the results, Type in the item you are counting into the cells adjacent to the formulas (for example "A"). Then use Data>Sort from the tool menu.

If you do sort them, then range(s) will need to set to constant by adding a "$" in front of each argument of the range as in this example "=COUNTIF($A$1:$A$9,"a")". Another way is to name the range of values by: highlighting the range and use Insert>Name>Define and then type in the name you want to use "Input" for example. Then the function would look like this "=COUNTIF(Input,"a")"

  • +1 for pointing out the insert function feature and how it can assist in creating a formula
    – datatoo
    Oct 22, 2010 at 15:42

There are a few tools that will help - primarily creating 'COUNTIF' fields which are then sorted will give you what you are after

I use Open Office as a base so I am unable to give a direct example

The '=COUNTIF(A1:A10;2006)' command allows you to specify the range then provide a value, if any cell equals the value, it will be counted.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .