Sorting dates

HomePro

Board Regular
Joined
Aug 3, 2021
Messages
157
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
  8. 2007
  9. 2003 or older
  10. Prefer Not To Say
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
I have a column on a sheet with date/ times I want to sort. But to do so I need to pad the day and the month. Or change the date format on the column. But it will not change.
Any idea why?


Appointment_General_Data.xlsx
A
1Added_Date
27/6/2022 8:55 AM
37/6/2022 9:02 AM
47/6/2022 9:03 AM
57/6/2022 9:09 AM
67/6/2022 10:26 AM
77/6/2022 12:18 PM
87/6/2022 12:26 PM
97/6/2022 12:43 PM
107/6/2022 1:33 PM
117/6/2022 2:26 PM
Sheet2
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Not sure what you mean. It sorts just fine for me.

Book1
ABC
1Added_Date
27/6/22 2:26 PM7/6/22 8:55 AM
37/6/22 8:55 AM7/6/22 9:03 AM
47/16/22 9:02 AM7/6/22 9:09 AM
57/6/22 9:03 AM7/6/22 12:18 PM
67/6/22 12:26 PM7/6/22 12:26 PM
77/6/22 9:09 AM7/6/22 12:43 PM
87/26/22 10:26 AM7/6/22 1:33 PM
97/6/22 12:18 PM7/6/22 2:26 PM
107/6/22 12:43 PM7/16/22 9:02 AM
117/6/22 1:33 PM7/26/22 10:26 AM
12
Sheet1
 
Upvote 0
If changing the format of the column has no effect on the data, then that means that your data is probably entered as text, and not as dates.
If you select the column, go to the Data menu and select "Text to Columns", and then got to Step 3 and choose the "Date" option with the proper Date order (don't know if it is in MDY or DMY in your data), and then click "Finish", it should convert those entries to dates, and then you should be able to sort them.
 
Upvote 0
VBA code to sort it:

VBA Code:
    Sheets("Sheet2").Range("A1:A11").Sort Key1:=Sheets("Sheet2").Range("A1"), _
                Order1:=xlAscending, DataOption1:=xlSortTextAsNumbers, Header:=xlYes
 
Upvote 0
HomePro - be aware that dates are stored as date-encoded numbers in excel. So if your data was entered as a text value (to see what the cell is formatted as, from the Home tab - Number grouping - the drop down box will show you if the cell is General, Number, Date, Time, Custom, ect.) Try changing the selection types and see what happens to your cell values. This is where you will really see the difference between a Date value and a Number value or if it is string text.
 
Upvote 0
not sure why but I can not seem to identify / change the format in general / text/ date formatting and I can not sort it as Johnnyl did above.
What is my next step to work this out?
 
Upvote 0
Did you try the steps I outlined in step 3?
Note that changing the the format of a column after the fact will NOT change the type of data that is located in that column (it will only format entries that are already valid numbers/dates - it will do nothing to text entries).
Doing a "Text to Columns" will re-convert the data and allow you to change the data type (from text to dates).
 
Upvote 0
yes i did. not sure why but seems that the spreadsheet works different than the converted xl2bb version
 
Upvote 0
yes i did. not sure why but seems that the spreadsheet works different than the converted xl2bb version
Can you post a print screen/image of your sheet, so we can see what it looks like?

Are some values left-justified int the cells and others right-justified?

It looks like your first value is in cell A2.
If you enter this formula in any blank cell on your sheet, what does it return?
Excel Formula:
=ISNUMBER(A2)
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,917
Members
449,093
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top