Log in
x
or
x
x
Register
x

or

How to sort cells by last character or number in Excel?

It is easy to sort cells by the first character in Excel. But when you need to sort cells by the last character or number in Excel, how could you do it? This article is going to show you some easy ways to sort cells by last character or number in Excel quickly.

Sort by last character or number with Right Function

Sort by last character or number with VBA

Sort cells by last characters or numbers with Kutools for Excel

Easily sort by last name/word in cells in Excel

Kutools for Excel's Advanced Sort utility supports sorting data by many flexible scenario/methods, such as sort by text length, sort by frequency, sort by last name, etc. Full Feature Free Trial 30-day!

ad sort by last name

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.

An example may be easy to understand. The following ways will show you how to sort the cells in the Column A by their last characters.

If we can extract the last characters from each cell, it will be easy to sort the cells by their last characters. Luckily, Microsoft Excel's Right function supports extracting the last letter or number form cells.

1.  Select a blank cell besides the column, says Cell B2, enter the formula of =RIGHT(A2,1), and then drag the cells's Fill Handle down to the cells as you need.

2. Keep selecting these formula cells, and click Data > Sort A to Z or Sort Z to A. In the opening Sort warning dialog box, check Expand the selection option and click Sort button. See screenshot:

3. Now data has been sorted. Please delete the formula cells as you need

Then you will see the cells in original Column A are sorted by their last characters.


You may also think of reverse the cell contents before sorting them by their last characters. Actually here is a VBA macro can help you.

1.  Hold down the Ctrl + F11 key to open the Microsoft Visual Basic for Application window.

2.  Click the Insert >> Module, and paste the following VBA code on the new Module window:

VBA: Extract the last character form a cell

Public Function RevStr(Rng As Range)
RevStr = StrReverse(Rng.text)
End Function

3.  Go back to the Microsoft Excel window, enter the formula of =RevStr(A1), and drag the cell's Fill Handle to the cells as you need.

4.  Click one of three Sort buttons under the Data button, and in the opening dialog box check the Expand the selection option and click the Sort button.

5. Delete the Column B.

Now it sort all cells in the column a by their last characters.


If we can reverse all characters’ order in cells, then we can sort these cells by the last character easily. Kutools for Excel’s Reverse Text Order utility can help you solve it easily as below screenshot shown:

1. Select the cells that you will sort by last character, and click Kutools > Text > Reverse Text Order.

2. In the opening Reverse Text dialog box, check Noting option and click OK button.

3. Now all characters are reversed in selected cells. Keep selecting these cells, and click Data > Sort A to Z or Sort Z to A. In the opening Sort warning dialog box, check Expand the selection option and click Sort button. See screenshot:

4. Now cells have been sorted by last character, and we need to restore characters’ order in these cells by repeating step 1-2.

Kutools for Excel - Includes more than 300 handy tools for Excel. Full feature free trial 30-day, no credit card required! Get It Now


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


The Best Office Productivity Tools

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. 60-day money back guarantee.
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.
  • To post as a guest, your comment is unpublished.
    MV · 1 years ago
    Thanks! This was very helpful!
  • To post as a guest, your comment is unpublished.
    Khan · 2 years ago
    Thanks! Great article
  • To post as a guest, your comment is unpublished.
    Pradipta Y · 2 years ago
    Great tutorial, very helpful for my project. Thank You
  • To post as a guest, your comment is unpublished.
    bunny · 4 years ago
    hii
    can u help how to aarange the the project codes in specifed order according to there last 3 digt code all 026 should colum by col
    examp
    '000’,
    'D-02-817816-026',
    'C-02-816770-026',
    'D-02-819610-088',
    'C-02-816770-026'
    'C-02-819386-088',
    'D-02-821120-027'
  • To post as a guest, your comment is unpublished.
    Sujin Sunny · 5 years ago
    My easy suggestion

    Suppose the column that you want to sort is titled PRODUCT_CODE

    Highlight the required cells (PRODUCT_CODE)

    In DATA option, click on FILTER. Beside the top cell on PRODUCT_CODE, you will see the filter option, when you click on it, the drop down pane will have the option of TEXT FILTERS.

    In TEXT FILTERS you will get the ENDS WITH option , or you can use the CONTAINS option. This will sort with exactly what criteria you require.

    eg: PRODUCT_CODE List contains
    NC007196 O
    NC007516 C
    NC007782 K
    NC007797 O
    NC007809 O
    NC007916 K
    NC007919 K
    NC007930 O
    NC007964 C
    NC008095 K
    NC008098 K
    NC008226 K
    NC008538 K
    NC008653 O
    NC008741 O
    NC008762 O
    NC008779 O
    NC008857 K
    NC008924 K
    NC008990 K
    NC009412 O
    NC009548 C
    NC009696 O
    NC009741 O
    NC009885 C
    NC009913 C
    NC009915 K

    if you use the highlight the column and FILTER it by ends with K, the result will give

    NC007782 K
    NC007916 K
    NC007919 K
    NC008095 K
    NC008098 K
    NC008226 K
    NC008538 K
    NC008857 K
    NC008924 K
    NC008990 K
    NC009915 K

    Hope this helps you out guys!
  • To post as a guest, your comment is unpublished.
    Rs yadav · 5 years ago
    good job my freind thank you..