Overcome a Nuance of Excel's Subtotal Feature

AccountingWEB
Share this content

By David Ringstrom, CPA

Many users rely on the Subtotal feature in Excel to instantly insert totals, averages, counts, or other statistics into a list. As you'll see, the feature is easy to use – until you want to copy or format just the total rows. In this article, I'll explain the nuance so that you'll be in complete control of this feature.

Figure 1 shows a typical data set for use with the Subtotal feature. We can use the Subtotal feature to insert a total after each product as well as a grand total at the bottom. As an added benefit, we'll then be able to expand and collapse our list by way of outlining buttons that will appear at the left. To do so:

  1. Select any cell within your list.
  2. Choose the Subtotal command on the Data tab in Excel 2007 and later, or the Data menu in Excel 2003 and earlier.
  3. Select the Cases Sold field, and then click OK.

Figure 1: Use the Subtotal feature to automate inserting totals within a list of data.

Figure 2 shows the newly inserted subtotals, along with outlining controls at the left-hand side of the worksheet. If you click the 1 button, the list will collapse down to just the total rows, as shown in Figure 3. 

Figure 2: The Subtotal feature inserted a total after each change in the Product column.

Figure 3: Click the 1 button to collapse the list down to just the total rows.

Click on cell A1 and then press Ctrl-A to select the contiguous block of data. Press Ctrl-C to copy, and then in a new worksheet, press the Enter key to paste your data. At this point the aforementioned nuance reveals itself. One would think Excel would copy and paste just the visible rows that contain the totals, but instead, Excel includes all of the rows, as shown in Figure 4. 

Figure 4: Even though we thought we copied just the total rows, Excel pasted all of the rows.

Similarly, any formatting that you apply would affect the hidden rows as well. Here's how to take charge of the situation:

  1. As shown in Figure 5, select the cells that you wish to copy or format.
  2. Press Ctrl-G to display the Go To dialog box and then click the Special button.
  3. Double-click Visible Cells Only.

Figure 5: Use the Go To Special command to select just the visible rows for copying or formatting.

At this point, you can copy or format just the total rows. You can access the Go To Special command in other ways as well:

  • In any version of Excel, press F5 instead of Ctrl-G.
  • In Excel 2007 and later, choose the Find & Select command on the Home Tab and then choose Go To Special.
  • In Excel 2003 and earlier, choose Edit, Go To, and then click the Special button.

N.B.: You don't need to use the Go To Special command with filtered lists (the Filter command in Excel 2007 and later, or the AutoFilter command in Excel 2003 and earlier). Only the visible rows are affected when you copy or format filtered lists, but with the Subtotal feature, the extra step of Visible Cells Only will help you keep your sanity.

Read more articles by David Ringstrom. 

About the author:

David H. Ringstrom, CPA heads up Accounting Advisors, Inc., an Atlanta-based software and database consulting firm providing training and consulting services nationwide. Contact David at [email protected] or follow him on Twitter. David speaks at conferences about Microsoft Excel, and presents webcasts for several CPE providers, including AccountingWEB partner CPE Link.

About David Ringstrom, CPA

David Ringstrom

David H. Ringstrom, CPA, is an author and nationally recognized instructor who teaches scores of webinars each year. His Excel courses are based on over 25 years of consulting and teaching experience. His mantra is “Either you work Excel, or it works you.” David offers spreadsheet and database consulting services nationwide.

Replies

Please login or register to join the discussion.

avatar
By Stephane
Jun 26th 2015 01:11

Works for me, thanks for the tip !

Thanks (0)
avatar
By David Ringstrom
to alnailor
Jun 26th 2015 01:11

You're welcome! I appreciate the feedback!

Thanks (0)
avatar
By Dave
to alnailor
Jun 26th 2015 01:12

I am using MS Excel v10. I am trying to step into my V.B. / Macro and add an entry that will insert a blank row after each line showing Total! Please tell me there is an easy way to do this. I am doing it manually now and when you have multiple sheets it becomes burdensome. Can you help me? Thanks, R, Dave

Thanks (0)
avatar
By Doug Masto
Jun 26th 2015 01:11

Excellent. Now if only I can remember this for the next time

Thanks (0)
avatar
By Damian
Jun 26th 2015 01:11

Extremelly useful, thanks a lot!

Thanks (0)
avatar
By David Ringstrom
to Malvika
Jun 26th 2015 01:11

My pleasure! I'm glad that you found the technique helpful.

Thanks (0)
avatar
By stevus
Jun 26th 2015 01:12

Brilliant advice. By far the best return on my Google search. Really useful. Thank you.

Thanks (0)