+ Reply to Thread
Results 1 to 9 of 9

Why Excel cannot sort a column with mixed letters and dates?

  1. #1
    Registered User
    Join Date
    07-06-2018
    Location
    Hong Kong
    MS-Off Ver
    2016
    Posts
    3

    Why Excel cannot sort a column with mixed letters and dates?

    I make some codes like the following and sort it in an A-Z order, the result is as follows:

    Allarts: China>Hong Kong>1/3/2013>a
    Allarts: China>Hong Kong>1/6/2013>a
    Allarts: China>Hong Kong>1/8/2015>a
    Allarts: China>Hong Kong>10/10/2015>a
    Allarts: China>Hong Kong>10/10/2015>b
    Allarts: China>Hong Kong>10/8/2013>a
    Allarts: China>Hong Kong>11/5/2013>a
    Allarts: China>Hong Kong>11/7/2015>a

    Apparently the sorting gets stuck on the date part (2015 float above 2013, or 11/5/2013 floats above 11/7/2013). I have already sought some general help from the Microsoft team. They taught me to change the format of that column to "value" and sort it again. They also said the Excel should be able to identify x/xx/xxxx as the dates and hence sort them from old to new as well, after sorting the text parts. I tried their advice but I still failed.

    Can anyone tell me what I should do to make the Excel able to sort the text with consideration to the chronological order of the dates?

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Why Excel cannot sort a column with mixed letters and dates?

    is that what you want?

    Allarts: China Hong Kong
    03/01/2013
    a
    Allarts: China Hong Kong
    06/01/2013
    a
    Allarts: China Hong Kong
    08/10/2013
    a
    Allarts: China Hong Kong
    05/11/2013
    a
    Allarts: China Hong Kong
    08/01/2015
    a
    Allarts: China Hong Kong
    10/10/2015
    a
    Allarts: China Hong Kong
    10/10/2015
    b
    Allarts: China Hong Kong
    07/11/2015
    a


    sort.jpg
    Last edited by sandy666; 07-06-2018 at 06:01 AM.

  3. #3
    Registered User
    Join Date
    06-04-2018
    Location
    Europe
    MS-Off Ver
    Office365
    Posts
    78

    Re: Why Excel cannot sort a column with mixed letters and dates?

    Hi,

    I guess you have this text: Allarts: China> Hong Kong> 1/3/2013> a, intro cell and not many, and excel sees that text as it is (what it is).
    If this is the case then the sorting is good because the excel sorts after the first letter, then after the 2nd, then the 3rd ... if the letters are the same.

    if you want to sort by date, use TextToColumn with the separator ">", and here sets the data column to be seen as the date, and then selects the date column and sorts.

  4. #4
    Registered User
    Join Date
    07-06-2018
    Location
    Hong Kong
    MS-Off Ver
    2016
    Posts
    3

    Re: Why Excel cannot sort a column with mixed letters and dates?

    The two methods above are to break each code into two parts i.e. the text and the dates, into two different columns, then sort the text and then the date.

    My problem is, i put the whole code into one cell (as I do not want to sort two times to complete the sorting) and I expect the Excel is able to identify the text and then the date even within one cell. The Microsoft Team guy says the Excel should be able to read x/xx/xxxx as the date and hence will be able to adjust its sorting criteria to "old to new (date)" after the text part, all at once, in one cell (unless I misunderstood him).

    Anyone has further insight about the above?

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Why Excel cannot sort a column with mixed letters and dates?

    Any time you mix text and numbers (a date is a number) the number becomes text - the whole cell is then text, and excel will sort it as text
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Registered User
    Join Date
    07-06-2018
    Location
    Hong Kong
    MS-Off Ver
    2016
    Posts
    3

    Re: Why Excel cannot sort a column with mixed letters and dates?

    Anyway to achieve what I want (a single sorting) if the whole code is put in a single cell?

    Does that mean I should really break it down into the text part and the date part and hence sort two times?

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Why Excel cannot sort a column with mixed letters and dates?

    Break it down - yes. Sort it twice - no. You do 1 sort but with 2 sort "levels", 1 for text and the 2nd for date

  8. #8
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Why Excel cannot sort a column with mixed letters and dates?

    You cannot sort it in-place but you can get result like you want.
    Use PowerQuery aka Get&Transform split it by > then sort and then merge columns and result load to the sheet back
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Why Excel cannot sort a column with mixed letters and dates?

    I think you can use TEXT TO COLUMNS first, but make sure you set up > as the delimiter, then move across to the date column, and set the date to DMY. If you don't do this, excel gets confused about dates that are not in the MMDDYYYYY format used in the USA.

    You can then sort in the usual way using the date column.

    I hope this helps, please let me know!

    Regards,

    David

    If this has been helpful
    - Please click on the *Add Reputation button at the bottom left.

    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".


+ 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. Sort Mixed Data With Periods, Letters, Numbers, Backslashes and Hyphens
    By officemate in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 06-16-2015, 01:59 PM
  2. How do I sort column with mixed letters and digits?
    By harproblem in forum Excel General
    Replies: 8
    Last Post: 01-16-2015, 06:04 PM
  3. Replies: 1
    Last Post: 08-27-2014, 11:05 AM
  4. Replies: 4
    Last Post: 03-20-2014, 01:39 PM
  5. Replies: 11
    Last Post: 02-11-2013, 08:10 AM
  6. [SOLVED] Adding Column of mixed data omitting the dates
    By lpullen in forum Excel General
    Replies: 2
    Last Post: 11-17-2005, 12:45 PM
  7. Sort mixed numbers/letters
    By V-ger in forum Excel General
    Replies: 1
    Last Post: 11-14-2005, 06:55 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