## 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

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.

Kutools for Excel - Packed with over 300 essential tools for Excel. Enjoy a full-featured 30-day FREE trial with no credit card required! Download now!

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:

Kutools for Excel - Packed with over 300 essential tools for Excel. Enjoy a full-featured 30-day FREE trial with no credit card required! Download now!

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.

Kutools for Excel - Packed with over 300 essential tools for Excel. Enjoy a full-featured 30-day FREE trial with no credit card required! Download now!

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.

### 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 Toolsets:  12 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...

#### 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!