How to sort strings by a second or third character in Excel?
In Excel, we usually sort data in ascending or descending order by the Sort utility. But the Sort utility only sorts the data based on the first character. How about sorting strings with the second or third or nth character as below screenshot shown? In this article, I introduce some tricks on solving this job.
General Sort | Sort by the second character |
![]() |
![]() |
Sort strings by the second character with formula
Sort strings by middle characters with Text to Columns
Sort strings by the second character with formula
To sort strings by the second or third character, you need a helper column.
1. Select a cell next to the strings you want to sort, and type this formula =RIGHT(A1,LEN(A1)-1), (A1 is the cell you use, -1 indicates to remove the first character from left) press Enter key and drag fill handle over the cells which needed this formula. Now the strings have been extracted except the first one character.
2. Keep formula cells selected, click Data > Sort A to Z, next check Expand the selection option and click the Sort button in Sort Warning dialog. See screenshot:
3. The data has been sorted by the second character. You can remove the helper column.
Sort strings by middle characters with Text to Columns
If you want to sort text strings only by several middle characters, you can use the Text to Columns function.
For instance, sort the phone numbers by middle two digits as below screenshot shown.
![]() |
![]() |
![]() |
1. Select the strings you use, and click Data > Text to Columns.
2. In the Convert Text to Columns Wizard dialog, check Delimited option in the first one step, click Next to check Other option in Delimiters section, and type the separator which is used to split the numbers in the textbox, then click Next to go to last step, and select a location to place new data. See screenshot:
![]() |
![]() |
![]() |
3. Click Finish, and the text strings have been split into columns, and select the column data which you want to sort strings by, click Data > Sort A to Z, and check Expand the selection option in the Sort Warning dialog. See screenshot:
4. Click Sort. Now the text strings have been sorted by middle characters, you can remove the helper columns.
Tip: If the text string has no separator to split characters, you can use this formula =MID(A17,3,2) to extract only the middle characters, then sort. In the formula, A17 is the cell you use, 3 indicates to extract the number third character from left, 2 means to extract 2 characters.
Best Office Productivity Tools
Supercharge Your Spreadsheets: Experience Efficiency Like Never Before with Kutools for Excel
Kutools for Excel boasts over 300 features, ensuring that what you need is just a click away...
Supports Office/Excel 2007-2021 & newer, including 365 | Available in 44 languages | Enjoy a full-featured 30-day free trial.
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
