Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to sort numbers with text/letter prefix or suffix in Excel?

For example you have a series of numbers containing letter prefix or suffix, how could you sort them as normal numbers in Excel? This article collects several workarounds to get it done.

Sort numbers with text/letter prefix or suffix by user defined function

Sort numbers with text/letter prefix or suffix by extracting numbers

Sort numbers with text/letter prefix or suffix by splitting text and numbers

Sort numbers with text/letter prefix or suffix by removing letters

Batch Separate text and numbers from one cell/column into different columns/rows

Kutools for Excel enhances its Split Cells utility and supports to batch separate all text characters and numbers of one cell/column into two columns/rows. Full Feature Free Trial 30-day!
ad split cell separate text numbers

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.


Sort numbers with text/letter prefix or suffix by user defined function

This method will introduce a user defined function (VBA) to extract numbers only from the numbers with prefix or suffix, and then you can sort easily.

1. Press Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and then paste below VBA code into the new opening Module window.

User Defined Function: Extract numbers only from text strings

Function num(rng As Range) As String
Dim n As Integer
For n = 1 To Len(rng)
If Mid(rng, n, 1) Like "[0-9]" Then
num = num & Mid(rng, n, 1)
End If
Next n
End Function

3. Save the code and close the Microsoft Visual Basic for Applications window.

4. Select a blank cell beside original numbers with prefix or suffix, says Cell B2, type the formula =num(A2) (A2 is the number with prefix or suffix) into it, and then drag this cell’s AutoFill Handle to the range as you need.

5. Due to extracted numbers stored as text, we need to convert them to numbers. Copy all extracted numbers, right click copied range and select Paste Values from the right clicking menu. See screenshot:

Note: In Excel 2007, you can copy the extracted numbers stored as text, and then click Home > Paste > Paste Values.

6. Keep selecting these numbers, and then click  button beside selected numbers, and select the Convert to Number from the drop down list. See screenshot:

7. Keep the new numbers selected, and click Data > Sort Smallest to Largest or Sort Largest to Smallest; and then check the Expand the selection option in the popping up Sort Warning dialog box, and click the Sort button. See screenshots:

8. Now the numbers with letter prefix or suffix have been sorted as normal numbers sorting (See below screenshot). Please delete the extracted numbers if necessary.


Sort numbers with text/letter prefix or suffix by extracting numbers

Actually, Kutools for Excel also provides similar EXTRACTNUMBERS function to extract numbers from text strings. Therefore, we can sort numbers with letter prefix or suffix by extracting numbers firstly.

1. Select a blank cell beside the numbers with letter prefix or suffix, says Cell B2, type the formula =EXTRACTNUMBERS(A2,TRUE) (A2 is the cell of number with letter prefix or suffix) into it, and then drag this cell’s AutoFill Handle to the range as you need. See screenshot:

2. Keep extracted numbers selected, click Data > Sort Smallest to Largest or Sort Largest to Smallest; check the Expand the selection option in the popping up Sort Warning dialog box, and then click the Sort button. See below screenshots:

3. Now numbers with letter prefix or suffix have been sorted as normal numbers sorting. And you can delete all extracted numbers as you need.


Sort numbers with text/letter prefix or suffix by splitting text and numbers

Kutools for Excel also supports to split text and numbers from cells by its Split Cells utility. Therefore, we can split the text and numbers and place them into different columns for easily sorting. Please do as follows:

1. Select the numbers with letter prefix or suffix, and click Kutools > Text > Split Cells. See below screenshot:

2. In the opening Split Cells dialog box, please check the Split to Columns option in the Type section, check the Text and number in the Split by section, and click the Ok button. See above screenshot:

3. Now the second Split Cells dialog box comes out. Please select the cell beside original numbers with letter prefix or suffix, says Cell B2, and click the OK button.
 

Now the texts and numbers are split and placed beside original numbers with prefix or suffix. See below screenshot.

4. Select the split numbers, and click Data > Sort Smallest to Largest or Sort Largest to Smallest; and then check the Expand the selection option in the popping up Sort Warning dialog box, and click the Sort button. See below screenshots:

5. Now the numbers with letter prefix or suffix have been sorted as normal numbers sorting. You can delete the split text and numbers as you need.


Sort numbers with text/letter prefix or suffix by removing letters

This method will introduce Kutools for Excel’s Remove Characters utility to remove all non-numeric characters (including letter) and leave numbers only in cells. And then you can sort numbers with text / letter prefix or suffix easily.

1. Copy all numbers with letter prefix or suffix, and then paste beside original numbers with letter prefix or suffix.

2. Keep selecting the pasted numbers, click Kutools > Text > Remove Characters, and then only check the Non-numeric option in the popping up Remove Characters dialog box, and click the Ok button. See below screenshot:

3. Now only numbers are left in the new column. Keep selecting these numbers, and click Data > Sort Smallest to Largest or Sort Largest to Smallest; and then check the Expand the selection option in the popping up Sort Warning dialog box, and click the Sort button. See below screenshots:

4. Delete the numbers as you need.


Demo: sort numbers with text/letter prefix or suffix in Excel

 

Kutools for Excel includes more than 300 handy tools for Excel, free to try without limitation in 30 days. Download and Free Trial Now!

Articles


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

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!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.