Excel Tip: Copy Subtotal (Aggregate) Data Only

July 4th, 2007 | by GTD Wannabe |

Have you ever used Excel’s subtotal functionality? It’s great for counting things. For instance, I’m running some tests right now, where the output is a sequence. If I run the test 10,000 times, then I have 10,000 sequences. I want to know how many times each sequence happens.

I copy the output into Excel, then sort the column containing the sequence into alphabetic order, thereby sticking like sequences with like. Then, I use the subtotal feature to count how many times each sequence occurs.

It’s great – it does exactly what I want. See the snapshot below.

The only problem I have is that sometimes I want to manipulate the aggregate information, say, calculate percentages, or compare it to some hand-created date from somewhere else. So, what I really want to work on is the aggregate data, not the underlying information.

As you can see in the diagram, there are actually over 10,000 rows of information in the sheet, even though I can hide all but 20-some. But, when I want to do a calculation on the data, I end up also doing the calculation on the *underlying* data as well. I can’t even just copy the subtotal information to somewhere else, because all of the underlying data comes too!

There has got to be a way around it. After some searching, and some bad suggestions (i.e., didn’t work for me), I discovered help in the form of Joseph Rubin’s ExcelTip.com. You can follow his instructions. It’s really easy. Basically, all you do is:

  1. In the view I have above, I just click on some cell in the data range, e.g., A260.
  2. Press Ctrl+A to select all of the subtotal data (would also include the underlying data).
  3. Magic Step: Press Alt+; (This selects only the *visible* cells. Magic!)
  4. Copy and paste as desired.

Wow, that little Alt+; step is pure magic. You can also get there by using the F5 key (which brings you up the Go To Dialog), selecting Special… and then selecting Visible cells only. Why you can select visible cells only by going through the “Go To” menu is completely beyond me.

As you can see in the screenshots below, selecting visible cells makes them look slightly different. The shot on the left (first) is the Ctrl+A selection (all data, including underlying, hidden, data). Notice the dark border. The shot on the right (second) is Alt+; selection (visible cells only). notice that the border is gone. A good visual way to make sure you’ve selected exactly what you want.

An interesting sidebar: I’ve just gone through the Help for Excel 2007. I originally went there, but had no joy when looking for information about copying and subtotals. But, if you search for “visible data”, you can get to a set of instructions that will let you copy just the subtotals. Funnily enough, there are no shortcut keys provided, just how to do the task with the ribbon. And, there’s not even a listing discussing what the Alt+; keyboard combination is good for! Shocking. It really is magic :)

  1. 9 Responses to “Excel Tip: Copy Subtotal (Aggregate) Data Only”

  2. By on Jul 4, 2007 | Reply

    I probably miss something, but why don’t you just make a big pivot table out fo the whole thing? Then you won’t even have to sort the data to start with.

  3. By on Jul 4, 2007 | Reply

    @micke: Good question. I have used pivot tables before, but they seem to be more suited to multi-dimensional data. Here, I just want to do a quick and dirty count, and then do other manipulations to the subtotals, without having to think about the underlying data.

    The point of the post wasn’t so much about sorting/subtotalling, but rather on how to copy what you can see, while ignoring what you can’t see :)

  4. By on Aug 16, 2007 | Reply

    That alt+; tip rocks!! You just saved me a lot of time — thanks for posting that! I just bought GTD, and I’m interested to read what else you have to say — I’ll be back. Thanks again!

  5. By on Aug 16, 2007 | Reply

    @Bob: Glad it helped Bob! It’s one of those silly little tricks that make you bang your head when you find out about it. “Why didn’t I know about this before…thump…thump…” :)

  6. By cs white on Feb 8, 2008 | Reply

    You saved my day on this one! I just switched over to 2007 and couldn’t figure out how to do this.

    thump, thump indeed.

  7. By Kerry on Sep 16, 2008 | Reply

    THIS SAVED ME HOURS! Thank you thank you thank you.

  8. By Roberta Brady on Sep 16, 2008 | Reply

    Thank you!!!!! I too searched the Microsoft web and found nothing useful (I did not look at “visible data”. This has saved me from re-typing hundreds of lines of data. Thank you!

  9. By Dinara on Sep 22, 2009 | Reply

    Thanks a lot!
    Pivot is not a good solution for the cases when subtotals represent multivariable sheet of data, when the only question is: how many unique categories of the specific variable are in this list. I tried to use pivot – it was huge mess with selection criteria and so on and so forth.
    So – thank you for the advice, anyway

  1. 1 Trackback(s)

  2. May 28, 2009: links for 2009-05-27 « The Adventures of Geekgirl

Sorry, comments for this entry are closed at this time.