Custom Sort Column by Time AM PM not working or Bug?

kellman

New Member
Joined
Aug 25, 2012
Messages
32
Office Version
  1. 365
Platform
  1. Windows
I'm trying to sort the Column by it's date & time AM/PM in order of earlier to oldest.

This was sorting correctly earlier, but now refuses to sort correctly.

Microsoft® Excel® for Microsoft 365 MSO (Version 2211 Build 16.0.15831.20098) 64-bit

It should list the time sorted as this:

8:00 AM
12:00 PM
4:00 PM

Instead I get the following weird order.

Dates with AM PM.xlsm
A
1Actual Appt Start
212/9/2022 12:00 PM
312/9/2022 4:00 PM
412/9/2022 8:00 AM
Sheet1


Note: I've tried with Cells formatted as Text and also by Date, no change
Tried Sort A-Z and Z-A and no change.
Rebooted computer with no change.
 

Attachments

  • Sort by AM PM Example.PNG
    Sort by AM PM Example.PNG
    32.7 KB · Views: 17
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
check the cells are still formatted as a date and not text

change the format to general

they should all change to a number

working for me
Book8
ABC
1Actual Appt StartFormat General
212/09/2022 8:00 am44816.33333
312/09/2022 12:00 pm44816.5
412/09/2022 4:00 pm44816.66667
5
Sheet1
 
Upvote 0
It appears to be sorting as text. Have seen this before. Change to General, then custom as h:mm:ss AM/PM and should work after that.
 
Upvote 0
check the cells are still formatted as a date and not text

change the format to general

they should all change to a number

working for me
Book8
ABC
1Actual Appt StartFormat General
212/09/2022 8:00 am44816.33333
312/09/2022 12:00 pm44816.5
412/09/2022 4:00 pm44816.66667
5
Sheet1
I have tried your solution and no change.

Address stripper test vba with data.xlsm
ABC
1Actual Appt StartFormat as General
212/9/2022 12:00 PM12/9/2022 12:00 PM
312/9/2022 12:00 PM12/9/2022 12:00 PM
412/9/2022 12:00 PM12/9/2022 12:00 PM
512/9/2022 4:00 PM12/9/2022 4:00 PM
612/9/2022 4:00 PM12/9/2022 4:00 PM
712/9/2022 8:00 AM12/9/2022 8:00 AM
812/9/2022 8:00 AM12/9/2022 8:00 AM
912/9/2022 8:00 AM12/9/2022 8:00 AM
1012/9/2022 8:00 AM12/9/2022 8:00 AM
Sheet1
 

Attachments

  • Sort by AM PM Format by General.PNG
    Sort by AM PM Format by General.PNG
    81.2 KB · Views: 19
Upvote 0
It appears to be sorting as text. Have seen this before. Change to General, then custom as h:mm:ss AM/PM and should work after that.
I have tried your solution and no change.
 

Attachments

  • Sort by AM PM Example 2.PNG
    Sort by AM PM Example 2.PNG
    63 KB · Views: 27
Upvote 0
they are TEXT and not dates - time
you should have seen numbers like i posted

so they will NOT sort by time

in a new cell - Add one to the value

A2+1
should add a day
as they are text - will get a value error
 
Upvote 0
If the underlying data is text, which it appears to be (left alignment), then changing the cell formatting will not change the values into numbers.

After you click OK to the Sort dialog shown in the post 1 image, don't you get an option like this?

1672704007991.png



Perhaps best anyway to convert them to actual date/time.
Select the data - Text to columns - Delimited - Next - Next - Choose Date and select whether you have DMY or MDY order for your dates - Finish
 
Upvote 0
Maybe I'll have to uninstall and reinstall MS Office 365.
I'll put money on that not helping. I suppose xl2bb formats your data because what I posted worked for me when I copied it. If you want to upload a wb copy somewhere, I or anyone who's ok with downloading it will take a look. You could remove everything else but the data you posted. After looking at your pic, I agree. Left justified means text unless you purposefully did that.
Also, select one of those cells and look for a single quote at the far left in the formula bar.
 
Upvote 0

Forum statistics

Threads
1,215,410
Messages
6,124,749
Members
449,186
Latest member
HBryant

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