Sorting Time/Date When Derived From A Formula

Woody Pecker

New Member
Joined
Apr 11, 2008
Messages
35
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I have some data which is in hh:mm ddd format, but is a result of a formula from some text based data, so the actual result (eg:- 03:21 Wed) might actually present as text.

How can I sort the column of data when it rolls through midnight into another day without the earlier times moving to the top

eg:-

15:32 Wed
20:00 Wed
21:30 Wed
22:00 Wed
23:30 Wed
23:51 Wed
00:01 Thu
00:30 Thu
00:30 Thu
01:00 Thu
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
The only way to sort this is to get it into standard date/time format (you can still display it as shown). What is the formula, and what is the original text that the formula refers to?
 
Upvote 0
MASTER Warehouse Outbound Schedule NEWxlsx.xlsm
ABCDEFGHIJKLMNOPQR
1WAREHOUSE OUTBOUND SCHEDULE -
2
3LOAD LAST DROP ON THE HEADBOARD
4
5RouteDelivery NameTrip PosPalletsActual Pallets LoadedProductLoad by Time -1hrActual Load TimeCarrierTrailer NumberDelivery refBayStart time Finish timeLoaded ByCommentsSUBBIE TIME ADJUSTMENT
621SN HEMEL HEMPSTEAD136NTS03:21 Wed44T COVENTRY03:21 Wed
Sheet1
Cell Formulas
RangeFormula
R6R6=IF(A6="","",IF(I6="",G6,IF(IF(IF($I6="44T COVENTRY",$G6,"")>"",IF($I6="44T COVENTRY",$G6,""),IF(IF($I6="DD COVENTRY",$G6,"")>"",IF($I6="DD COVENTRY",$G6,""),""))="",TEXT(IF(IF(IF(IF($I6="44T COVENTRY",$G6,"")="",IF(IF($I6="DD COVENTRY",$G6,"")="",$G6,FALSE()))=FALSE(),"",IF(IF($I6="44T COVENTRY",$G6,"")="",IF(IF($I6="DD COVENTRY",$G6,"")="",$G6,FALSE())))="",IF(IF($I6="44T COVENTRY",$G6,"")>"",IF($I6="44T COVENTRY",$G6,""),IF(IF($I6="DD COVENTRY",$G6,"")>"",IF($I6="DD COVENTRY",$G6,""),"")),LEFT(IF(IF(IF($I6="44T COVENTRY",$G6,"")="",IF(IF($I6="DD COVENTRY",$G6,"")="",$G6,FALSE()))=FALSE(),"",IF(IF($I6="44T COVENTRY",$G6,"")="",IF(IF($I6="DD COVENTRY",$G6,"")="",$G6,FALSE()))),5)-TIME(1,0,0)),"hh:mm")&" "&RIGHT($G6,3),IF(IF(IF(IF($I6="44T COVENTRY",$G6,"")="",IF(IF($I6="DD COVENTRY",$G6,"")="",$G6,FALSE()))=FALSE(),"",IF(IF($I6="44T COVENTRY",$G6,"")="",IF(IF($I6="DD COVENTRY",$G6,"")="",$G6,FALSE())))="",IF(IF($I6="44T COVENTRY",$G6,"")>"",IF($I6="44T COVENTRY",$G6,""),IF(IF($I6="DD COVENTRY",$G6,"")>"",IF($I6="DD COVENTRY",$G6,""),"")),LEFT(IF(IF(IF($I6="44T COVENTRY",$G6,"")="",IF(IF($I6="DD COVENTRY",$G6,"")="",$G6,FALSE()))=FALSE(),"",IF(IF($I6="44T COVENTRY",$G6,"")="",IF(IF($I6="DD COVENTRY",$G6,"")="",$G6,FALSE()))),5)-TIME(1,0,0)))))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
R6Expression=R6=G6textNO
I2:I1048576Cell Valuecontains "COVENTRY DOUBLE MAN"textNO
I2:I1048576Cell Valuecontains "COVENTRY DOUBLEMAN"textNO
I2:I1048576Cell Valuecontains "COVENTRY DRIVER"textNO
G5:H5Expression=($A5=$A3)textYES
P5Expression=($A5=$A3)textYES
O5Expression=($A5=$A3)textYES
A5:F5,I5:N5,R5Expression=($A5=$A3)textYES
J5Expression=($A5=$A3)textYES
J5Expression=(#REF!=TRUE)textYES
A27:P38,A40:P1801,A5:P5,A7:P25,R5Expression=($A5=$A4)textYES
A6:P6Expression=($A6=#REF!)textYES
 
Upvote 0
The formula in R refers back to G6. Is G6 typed in as text?
 
Upvote 0
How do you get that data into your sheet currently?

The best solution is to enter column G as date/time data instead of text. Such as

12/12/2021 03:21

and use a custom format

hh:mm Ddd

so that it displays the same way as now.

Otherwise if you want to sort column R you have to modify every reference to G6 in your formulas to this. The big problem here is with just a day of the week, we don't know what the actual date is. You need to have some baseline date that tells us what week we are talking about. Let's say we put Monday's date in A2, then this formula converts G6 to a sortable value:

=TIMEVALUE(LEFT(G6,5))+MATCH(RIGHT(G6,3),{"Mon","Tue","Wed","Thu","Fri","Sat","Sun"},0)+$A$2-1

Needless to say this will make your formula very long. Better to put in date/time data to start with.

$scratch.xlsm
ABCDEFGH
1
212/13/2021
3
4
5OriginalDate/Time Value
603:21 Wed03:21 Wed
Sheet4
Cell Formulas
RangeFormula
H6H6=TIMEVALUE(LEFT(G6,5))+MATCH(RIGHT(G6,3),{"Mon","Tue","Wed","Thu","Fri","Sat","Sun"},0)+$A$2-1
 
Upvote 0
Solution

Forum statistics

Threads
1,214,579
Messages
6,120,365
Members
448,956
Latest member
Adamsxl

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