0

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.

5 Answers 5

2

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: http://www.mrexcel.com/forum/showthread.php?t=82770

1
  • Thanks for the link. I'll post code when/if I get it all working. Apr 9, 2010 at 19:16
1

In Office 365, I was able to record my two Excel sorts as macros and link them to shortcut keys so that I can easily switch back and forth. I would not recommend using recorded macros for a notebook that is already using VBA for other purposes. However, this does make it possible to accomplish a "switch view" type functionality in an Excel notebook without requiring knowledge of VBA.

0

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."

1
  • This is undone if a filter is applied to that same sheet. Apr 22, 2020 at 10:59
0

One way that I know to have Excel 2010 remember the sorting criteria is if we do it this way: click on 1 cell (not highlighted all cells). Then Data/sort, and enter the sort criteria and save. The next time we open Excel and try to sort the same sheet, it will remember.

-1

This free add-in provides what you asked for. The code is unprotected so you can see how it works: https://sites.google.com/site/beyondexcel/project-updates/savesortsfilterscolumnsettings

2
  • 1
    While this may answer the question, please consider adding what is this, how this works, and summary how to use it (if possible add screenshot). As it is now, it is a spam and should be deleted.
    – Vylix
    Jul 19, 2017 at 13:55
  • 1
    Please read How do I recommend software for some tips as to how you should go about recommending software. You should provide at least a link, some additional information about the software itself, and how it can be used to solve the problem in the question.
    – DavidPostill
    Jul 19, 2017 at 14:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .