Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On an Excel 2007 worksheet, I have several tables, each sharing the same columns. For every table, I sort in several particular ways, depending on the task at hand. It gets tedious going to the Data tab, clicking Sort, unchecking the "my data has headers" checkbox, then add/removing the columns and ordering sort criteria.

Is it possible to: * Save a given sort criteria (a named sort)? * Apply the sort against any selected range? * Create a button to execute each saved sort?

In the end, I would create 4 or 5 named sorts and a button for each on the worksheet. Then would be able to select any range of rows, from any table, and click one of the sort buttons. The sort would execute.

share|improve this question
up vote 2 down vote accepted

You basically nailed the concepts. Behind each button it would run some VBA code that causes the sort to occur on the data table in the way you want it.

Sample code here:

share|improve this answer
Thanks for the link. I'll post code when/if I get it all working. – Robert Kerr Apr 9 '10 at 19:16

You don't need any code for this. Just select the cells in the header when you are customizing your sort. And the sorting criteria will be saved. Tested OK on Excel 2010.

Reference: "If a cell in the header row is selected the 'sort by' criteria is saved."

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.