Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Counting with Subtotals.

Counting with Subtotals

by Allen Wyatt
(last updated January 2, 2018)


Suppose that you have two adjacent columns of data. In the first column you have a list of names and in the second column a list of states. If you want to find out how many people live in each state, you can use the subtotaling features of Excel. To use this feature to answer your query, follow these steps:

  1. Make sure there are column heads on each column, such as "Name" and "State." (The subtotaling feature requires the presence of column heads.)
  2. Sort the columns by the values in the second (states) column.
  3. Make sure one of the cells is still selected in either of the columns.
  4. Display the Data tab of the ribbon.
  5. In the Outline group click the Subtotal tool. Excel displays the Subtotal dialog box. (See Figure 1.)
  6. Figure 1. The Subtotal dialog box.

  7. Make sure the At Each Change In drop-down list is set to State. (Use the name of the second column.) This indicates where Excel will insert subtotals.
  8. The Use Function drop-down list should be set to Count.
  9. Using the list in the Add Subtotal To box, choose the columns to which subtotals should be added.
  10. Make sure the Summary Below Data check box is selected.
  11. Click on OK.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8035) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Counting with Subtotals.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...


Opening Documents in Print Layout View

If you have a Word 2003 document that always seems to open in reading layout mode, you may want to turn that "feature" ...

Discover More

Adding a Drop Shadow to a Text Box

Drop shadows add a nice touch to text boxes, making it seem like they are hovering above the page. Here's the simple ...

Discover More

Converting to Octal

If you need to do some work in the base-8 numbering system (octal), you'll love two worksheet functions provided by Excel ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Making Revisions

You've turned on Highlight Changes, but how do you know what has been changed? This tip explains how Excel displays those ...

Discover More

Converting Imported Information to Numeric Values

If the information you import into Excel is treated as text by the program, you may want to convert it to numeric values. ...

Discover More

Non-Printing Controls

Don't want your form controls to print out with your worksheet? Here's how to make sure that Excel excludes them from ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is five more than 3?

2018-01-02 06:46:39

Paul Seaman

Excel's counting functions do not count blank cells.

To be sure your subtotal count is correct, in step 8 choose the same column you chose in step 6 (so in Allen's example choose "State" in both steps).

In Allen's example, this will correctly count how many times each state appears in the "State" column, regardless of whether there are any blanks in the "Name" column

2018-01-02 05:37:08


Hi there, it does not work in tables or with tables.

This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.