Results 1 to 18 of 18

Simplify this complex formula I've come up with for sorting mixed format time.

Threaded View

  1. #1
    Registered User
    Join Date
    03-12-2015
    Location
    UK
    MS-Off Ver
    2013 & 2010
    Posts
    27

    Question Simplify this complex formula I've come up with for sorting mixed format time.

    I have a worksheet of around 750 rows, each row having a time, accurate to the tenth of a second, and falling anywhere between 10 seconds and 9 minutes . I need to be able to sort the worksheet by the 'Time' column, however my problem was that, for reasons it would take me a long time to explain here, the times below 1 minute e.g. 53.4 seconds had to be displayed in exactly that format (53.4, not 00:53.4 "mm:ss.0"). However for the times above or equal to a minute, these do need to be formatted as mm:ss.0 This means I essentially have a list where excel thinks some of the values are numbers, and some of the values are times but needed to work out how to sort it correctly. For example this list:
    5:00.1, 1:45.6, 9.3, 9:13.4, 34.5, 1.8 would be sorted into this: 1.8, 9.3, 34.5, 1:45.6, 5:00.1, 9:13.4

    I have come up with a long winded method I feel will be able to be simplified, but it seems to work. Any input or suggestions would be appreciated.

    The times are in column A, with the column cells formatted as "general". I next added a 'number column' in column B referencing column A but formatted as "number". This was to to convert the times of a minute or more to their time code value e.g. if there is the time 1:12.4 in a row in column A, that becomes 0.000837963 in column B but 59.6 for example remains as 59.600000000. In column C I then came up with this mean looking formula:

    =ROUNDDOWN(IF(D2>=60,D2/60,D2),0)&IF(D2>=60,":",".")&IF(D2>=60,RIGHT(IF(IF(MID(A2,LEN(A2)-1,1)=".",
    0,ROUND((VALUE(IF(B2>1,A2/86400,A2))*1433.3333333),0))=0,TEXT(IF(IF(B2>1,A2/86400,A2<60,IF(B2>1,A2/86400,A2),""),"ss.0")
    ,IF(MID(A2,LEN(A2)-1,1)=".",0,ROUNDDOWN((VALUE(IF(B2>1,A2/86400,A2))*1433.3333333),0))&":"&TEXT(IF(IF(B2>1,A2/86400,A2<60
    ,IF(B2>1,A2/86400,A2),""),"ss.0")),4),RIGHT(IF(IF(MID(A2,LEN(A2)-1,1)=".",0,ROUND((VALUE(IF(B2>1,A2/86400,A2))*1433.3333333),0))
    =0,TEXT(IF(IF(B2>1,A2/86400,A2<60,IF(B2>1,A2/86400,A2),""),"ss.0"),IF(MID(A2,LEN(A2)-1,1)=".",0,ROUNDDOWN((VALUE(IF
    (B2>1,A2/86400,A2))*1433.3333333),0))&":"&TEXT(IF(IF(B2>1,A2/86400,A2)<60,IF(B2>1,A2/86400,A2),""),"ss.0")),1))


    Finally I put this formula into column D: =IF(A2<1,A2*86400,A2)

    Sorting A1:D750 by column D, which is essentially a 'seconds' column (and hiding columns B,C, and D) this method seems to work in Excel 2013 as I intended, but i got a feeling i've massively over complicated the long formula in column C and it would be cool to find a method without so many helper columns needed
    Last edited by timiop2011; 03-12-2015 at 04:51 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Sorting Mixed Text and Numbers
    By snapfade in forum Excel General
    Replies: 15
    Last Post: 08-29-2019, 01:23 PM
  2. Create a Procedure
    By lab_harts in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2015, 02:45 PM
  3. Sorting mixed content.
    By metsci in forum Excel General
    Replies: 3
    Last Post: 03-29-2014, 03:59 PM
  4. Sorting mixed data cells
    By JorisDDS in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-19-2014, 05:44 PM
  5. Simplify a complex formula
    By Kosherboychief in forum Excel General
    Replies: 15
    Last Post: 06-20-2011, 09:34 AM

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