+ Reply to Thread
Results 1 to 7 of 7

Looking for a way to sort a range of cells that are text based that contain numbers.

  1. #1
    Registered User
    Join Date
    09-19-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Looking for a way to sort a range of cells that are text based that contain numbers.

    Hi all.
    I am very limited with my excel VBA skill levels and would love some help to a problem I am facing.
    I have a spreadsheet that is pulling allocated points for individuals from other spreadsheets.
    Because the formula returns a text based result, when sorting the numbers the results are 1,10,11,12,2,20,21 etc.

    Is there away to sort the numbers in the text only low to high? the code I have used is also below.



    Please Login or Register  to view this content.
    Any help would be greatly appreciated.
    Attached Images Attached Images
    Last edited by scam; 05-26-2020 at 06:32 AM.

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Looking for a way to sort a range of cells that are text based that contain numbers.

    You could create helper columns next to each one you wish to sort. In the helper column you would have a formula that parses out the number from the text in the column next to it (using MID() and FIND() functions). Your VBA would then select the helper column and the one next to it, but using the helper column as the one to sort. You could hide the helper column so that it does not appear on your main view.
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Looking for a way to sort a range of cells that are text based that contain numbers.

    scam,

    Picture doesn't help at all.


    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  4. #4
    Registered User
    Join Date
    01-15-2020
    Location
    somewhere
    MS-Off Ver
    2016
    Posts
    30

    Re: Looking for a way to sort a range of cells that are text based that contain numbers.

    why not just add a second digit to them all if less than 100 (like 00, 01, 02)?

  5. #5
    Registered User
    Join Date
    09-19-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Looking for a way to sort a range of cells that are text based that contain numbers.

    Great suggestion for adding helper columns but the cells are being moved sometimes prior to sorting so helper cells would be incorrectly referencing blanks. I think I could make this work though.
    Last edited by scam; 05-29-2020 at 12:14 AM.

  6. #6
    Registered User
    Join Date
    09-19-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Looking for a way to sort a range of cells that are text based that contain numbers.

    Like the second digit idea it should work. I think if I used the text function in the formula with 00 as placeholders, it should sort the way I want.

  7. #7
    Registered User
    Join Date
    09-19-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Looking for a way to sort a range of cells that are text based that contain numbers.

    Quote Originally Posted by Metaldrgn View Post
    why not just add a second digit to them all if less than 100 (like 00, 01, 02)?
    So I added the function text(A1,"0000") into my formulas and instead of showing 1,2 3 etc now shows 0001,0002,0003 etc. Sorting works fantastic now. Thanks for the idea.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Formula needed for add a range of cells based on date range and text in other cells
    By excelteam777 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-15-2020, 08:36 PM
  2. [SOLVED] VBA to sequentially sort a numeric range of cells based on specific criteria
    By Portuga in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-07-2018, 06:23 AM
  3. Sort / subsort a range of cells based on the cell selected ??
    By James_36 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2018, 08:01 AM
  4. [SOLVED] Lock/Unlock range cells based on text value in other range cells
    By boboivan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-12-2014, 12:50 PM
  5. [SOLVED] Add up cells based on text within a date range
    By Munkle555 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-02-2013, 09:06 AM
  6. Sort Cells In Descending Order Based on Text String
    By kmccabe in forum Excel General
    Replies: 7
    Last Post: 08-01-2012, 05:58 PM
  7. Set variable sort range based on found text
    By jeffbert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2006, 05:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1