Home / Formulas / Worksheet Custom Sort

Worksheet Custom Sort

The ExcelHelpDesk Support team received the following request for help

Problem – Sort by Last Two Digits

I’m trying to find a formula where I can take the last 4 digits of the social security and sort it by using the last two digits only. For example:
And so on. Any help would be greatly appreciated. Thank you…

For this problem we received a copy of the workbook. We then used a formula to extract the last two digits of the text string. From there we sorted the worksheet by the extracted digits to acheive the result. Find below a screen shot of the un-sorted list, the formula used and then the sorted list.

Let us know if you need help in applying the sample to your situation.

Sample Un-sorted List

See below an example of the data provided for sorting

Step 1 – Include RIGHT Formula

Now before we can sort this list by the last two digits we need to extract the digits from the existing string. We can do this using the RIGHT formula on the existing string. See the formula for the first row of the sample sheet below.

Step 2 – Now Sort the new Column

Now simply drag that formula down until the last value in Column B is extracted. Then select the entire range from A2:C592 and sort the range using the new column of two digits in ascending order. See below for the sorted result.

If you have a question on this post for the Excel Help Desk team or have something you would like to share on this topic then please leave a comment

About Excel Help Desk

Check Also

INDIRECT to extract a value from another worksheet

You can see that we have the Worksheet name in Column A and the value that is needed to be extracted in Column D. The supplied worksheet included a manually entered formula to pull through the value from the other worksheet. We will now demonstrate how to create a formula using the INDIRECT function that will automatically pull through values from other worksheets without manually entering each worksheet name and cell reference.