Written by Allen Wyatt (last updated April 5, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365
Arnie volunteers for a veteran's group. He put the group's members in a workbook based on where they provided their service, such as Army, Navy, Air Force, etc., one worksheet per service branch. One column on each worksheet is the member's current rank or rank when they retired. Arnie wondered if there is a way to sort the membership on a single worksheet based on rank.
There are several ways that Arnie could approach this task. Before looking at each of them, though, it should be noted that Arnie doesn't indicate the country in which he is located. So, in providing approaches to the issue, I need to make some assumptions, the biggest one relating to country. So, I'm going to use United States armed forces rankings in this tip. Even so, the techniques described could be easily adapted to working with armed forces rankings in other countries.
The second assumption is based on what Arnie stated—that he has individual worksheets for each service branch. There are rank differences among service branches, and rather than go into all those differences here, I'm going to focus on a single service branch (US Army) to illustrate the approaches. The approach can then be adjusted, as necessary, for each branch.
With all that in mind, let's turn to three different approaches that Arnie could use for sorting his group by military rank.
One approach is to use a helper column to indicate a sorting number for the individual's rank. For instance, you might use 1 to indicate a general, 2 for a colonel, 3 for major, 4 for captain, and so on. Then, when it comes to sort, you could use the helper column as the primary sorting key.
You could take it one step further and add your ranks in a named range. For instance, you could place the ranks in column Z, select the range, and assign it the name ArmyRanks. Then, in your helper column you could use this formula that references the individual's rank in column C:
=MATCH(C1,ArmyRanks,0)
The returned value would be the numeric position of the rank within the ArmyRanks range. You can then sort by the values in the helper column.
In the US armed services, rank and paygrade are closely related. You can easily see this if you visit the following webpage:
https://www.defense.gov/resources/insignia/
Note the paygrade column, E-1 through E-9, W-1 through W-5, and O-1 through O-10. If you put a person's paygrade in a column, it makes sorting much easier. The drawback, of course, is that some paygrades have more than one rank assigned to them—for instance, in the Army both Corporal and Specialist are E-4 and both Master Sergeant and First Sergeant are E-8. In those instances, you could use the paygrade as the primary sort key and the rank as the secondary sort key.
One big advantage to the paygrade approach is that it applies to all branches of service, whereas rank does not. For instance, a captain in the Navy is very different from a captain in the Army. A Navy captain is equivalent to an Army colonel; both are at paygrade 0-6. Sort by the paygrade, and you have the ranks in the proper order for each service branch.
Excel allows you to create custom sort orders for situations just like those being faced by Arnie. The first step is to list, in proper ascending order, the ranks. Then, follow these steps:
Now you can use this custom sorting order with the ranks. Since rank ordering differs by service branch, you will need to create a custom sort order for each branch.
You can find more about custom sort orders at this Microsoft site:
https://support.microsoft.com/en-us/office/cba3d67a-c5cb-406f-9b14-a02205834d72
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7924) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365.
Dive Deep into Macros! Make Excel do things you thought were impossible, discover techniques you won't find anywhere else, and create powerful automated reports. Bill Jelen and Tracy Syrstad help you instantly visualize information to make it actionable. You’ll find step-by-step instructions, real-world case studies, and 50 workbooks packed with examples and solutions. Check out Microsoft Excel 2019 VBA and Macros today!
Using the sorting tools, on the toolbar, may result in some unwanted results, such as jumbled data. If this happens to ...
Discover MoreIf the font color used for the data in your worksheet is critical, you may at some time want to move cells that use a ...
Discover MoreExcel is great at sorting information in a worksheet. Sometimes it can be a bit confusing as to how to set up the sort ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2025-04-06 10:15:31
J. Woolley
Re. Create a Custom Sort Order, the Tip fails to mention how to sort with the custom list. First select the range to be sorted, then click Data > Sort; under Order in the Sort dialog, pick Custom List and select the new list of ranks. This is explained in the referenced Microsoft site. For more on this subject, see https://excelribbon.tips.net/T008733
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments