Problem: I want to subtotal revenue and count the number of records. The Subtotal dialog offers 11 different summary functions including two counting functions. How do I change the function for different columns?
I've tried adding the SUM to Revenue, then doing subtotals a second time to count the customer, but the subtotals end up on two different rows.
Strategy: When you add subtotals, Excel makes use of a function called =SUBTOTAL(). The first argument of the SUBTOTAL function tells Excel which summary function to use.
=SUBTOTAL(9, is the argument for sum. There are 11 functions to choose from. Microsoft arranged the arguments alphabetically.
- SUM is ninth alphabetically. That explains the 9.
The solution is to add automatic subtotals to the numeric columns and the text column that you want to count. Of course, the totals on the text column will be zero.
- Total a text column.
- Select the entire text column.
- Use Ctrl+H to display the Find and Replace dialog.
- Type (9, in the Find What box.
- Type (3, in the Replace With box.
- Press Replace All.
- Change the 9 argument to 3.
This will change the SUBTOTAL function from one that sums to one that counts text entries. You will have a count in column A and a sum in column E.
- Counts and sums on the same row.