Skip to main content

How to sort strings by a second or third character in Excel?

Author: Sun Last Modified: 2017-12-27

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
doc sort by nth character 1 doc sort by nth character 2

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.
doc sort by nth character 3

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:
doc sort by nth character 4

3. The data has been sorted by the second character. You can remove the helper column.
doc sort by nth character 5


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.

doc sort by nth character 6 doc arrow right doc sort by nth character 7

 

1. Select the strings you use, and click Data > Text to Columns.
doc sort by nth character 8

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:

doc sort by nth character 9
doc sort by nth character 10
doc sort by nth character 11

 

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:
doc sort by nth character 12

4. Click Sort. Now the text strings have been sorted by middle characters, you can remove the helper columns.
doc sort by nth character 13

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.
doc sort by nth character 14

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


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!
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations