+ Reply to Thread
Results 1 to 19 of 19

Formatting Numarical Values with Custom Formatting

  1. #1
    Registered User
    Join Date
    07-11-2014
    Location
    North Carolina
    MS-Off Ver
    2010
    Posts
    30

    Formatting Numarical Values with Custom Formatting

    Hello:
    I am attempting to solve a problem with either formatting or the equation itself to display a numerical value.

    In cells "D" & "E" I have a custom format to display a time value in military time without entering in the the colon >>>formatting 00\:00<<<. This solved the problem of entering in a colon each time I needed to enter in a time. i.e if 1330 is entered in the cell the formatting converts to 13:30.
    What I needed to do secondly is calculate the time difference between cells "D" & "E". So 13:30 in cell "D" and 1400 in cell "E". The difference is 30mim as time however its 70 when excel calculates the difference due to excel reading 13:30 and 14:00 as 1400 - 1330 which = 70. OK so I understand that issue and found away around it.
    The formula I found works to calculate what I'm needing and looks like this >> =TEXT(E4,"00\:00")-TEXT(D4,"00\:00")+(E4>D4) <<. This equation functions to work the math to the correct outcome i.e 14:00 - 13:30 = 30. The formatting in the calculation cell is set to custom hh:mm which displays the math as 00:30.
    (I hope that explained what I've done and where I'm at now)

    What I need to know how to do is either a calculation modification to convert 00:30 to read 30 for 30min or 120 for 2hrs and so on such as 2hrs 45min reads 165. Or is custom formatting or even conditional formatting that could be used to display the time the way I'm needing?

    Also I tried to use the equation and /24 to see if that worked and tried every formatting option excel had to offer

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Formatting Numarical Values with Custom Formatting

    Try this:

    =(TEXT(E4,"00\:00")-TEXT(D4,"00\:00")+(E4>D4))*24*60

    Format the cell as General.

    Hope this helps.

    Pete

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Formatting Numarical Values with Custom Formatting

    multiply the time by 24*60 format general so 02:45*24*60 =165 or just multiply by 1440
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Registered User
    Join Date
    07-11-2014
    Location
    North Carolina
    MS-Off Ver
    2010
    Posts
    30

    Re: Formatting Numarical Values with Custom Formatting

    I entered in the alteration to the equation >> =(TEXT(E4,"00\:00")-TEXT(D4,"00\:00")+(E4>D4))*24*60 << Changed formatting to general and entered in my times and it added up to 1445, when the difference was just 35.
    Did I enter in something wrong??
    Would I need a macro to do the calculation after the fact i.e I let the original equation do its math and formatting be entered as is, then the macro takes over after data has been entered in the cell and formulates the 00:00 to the number value I'm after?

  5. #5
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Formatting Numarical Values with Custom Formatting

    Oh man..
    Just use -40 at end of your first formula..


    Say thanks, click *

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Formatting Numarical Values with Custom Formatting

    @ Vikas_Gautam
    Oh man..
    Just use -40 at end of your first formula..
    err no that will not work
    1400-1330 =70 - 40 =30 looks ok
    but what of
    1400-1200 =200 -40 =160 when the answer is 120


    @ excelneub

    what values are in e4 and d4?

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Formatting Numarical Values with Custom Formatting

    Another way:

    D
    E
    F
    G
    3
    Format of D4: 00\:00 Format of E4: 00\:00 Format of F4: h:mm
    4
    13:30
    14:00
    0:30
    F4: =MOD(SUMPRODUCT(DOLLARDE(D4:E4/100, 60), {-1,1}) / 24, 1)
    5
    14:00
    13:30
    23:30
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Formatting Numarical Values with Custom Formatting

    Use an extra code...
    =lookup(difference,{0;100;200;300;400},{40;80;120;160;200})

    just minus the ans from the differential....

  9. #9
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Formatting Numarical Values with Custom Formatting

    You can extend this array to the maximum possibility of 2400..

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formatting Numarical Values with Custom Formatting

    Maybe you can do this:

    Quick Time Entry

    Then you won't have to use a convoluted formula to get the results!
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  11. #11
    Registered User
    Join Date
    07-11-2014
    Location
    North Carolina
    MS-Off Ver
    2010
    Posts
    30

    Re: Formatting Numarical Values with Custom Formatting

    I entered in your formula and formatted the cell to h:mm. When I entered in the times to formula gave me this #NAME?

  12. #12
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Formatting Numarical Values with Custom Formatting

    who are you talking to? you havent answered my question post #6
    did you try the suggestion in post #7
    try this
    =MOD((TEXT(E4,"00\:00")-TEXT(D4,"00\:00")),1)*24*60
    Last edited by martindwilson; 07-11-2014 at 03:23 PM.

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formatting Numarical Values with Custom Formatting

    Looks like the reply is to shg in post #7.

    Instead of *24*60 why not just *1440?

  14. #14
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Formatting Numarical Values with Custom Formatting

    see post 3 , i was just amending petes to work

  15. #15
    Registered User
    Join Date
    07-11-2014
    Location
    North Carolina
    MS-Off Ver
    2010
    Posts
    30

    Re: Formatting Numarical Values with Custom Formatting

    Quote Originally Posted by martindwilson View Post
    who are you talking to? you havent answered my question post #6
    did you try the suggestion in post #7
    try this
    =MOD((TEXT(E4,"00\:00")-TEXT(D4,"00\:00")),1)*24*60
    Sorry about that; I was trying to respond to your answer only hit the wrong reply.
    I have tried both of your suggestions and I'm unable to come up with the results I'm looking for I have to be entering something wrong.

    Under general formatting =MOD((TEXT(E4,"00\:00")-TEXT(D4,"00\:00")),1)*24*60<< is giving me a "0".
    I'll figure this thing out one way or another. Thank you for your help.

  16. #16
    Registered User
    Join Date
    07-11-2014
    Location
    North Carolina
    MS-Off Ver
    2010
    Posts
    30

    Re: Formatting Numarical Values with Custom Formatting

    Quote Originally Posted by Pete_UK View Post
    Try this:

    =(TEXT(E4,"00\:00")-TEXT(D4,"00\:00")+(E4>D4))*24*60

    Format the cell as General.

    Hope this helps.

    Pete
    This got me to where I needed relating to the getting the math to come out right. However I'm having problems getting it to show up as only numbers i.e 2hrs 5min looks like 02:05 instead of 125.

  17. #17
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Formatting Numarical Values with Custom Formatting

    Lots of variations ...

    D
    E
    F
    G
    3
    Format of D4: 00\:00 Format of E4: 00\:00 Format of F4: h:mm
    4
    13:30
    14:00
    0:30
    F4: =MOD(SUMPRODUCT(TEXT(D4:E4, "0\:00")*{-1,1}), 1)
    5
    14:00
    13:30
    23:30

  18. #18
    Registered User
    Join Date
    07-11-2014
    Location
    North Carolina
    MS-Off Ver
    2010
    Posts
    30

    Re: Formatting Numarical Values with Custom Formatting

    Quote Originally Posted by excelneub View Post
    Sorry about that; I was trying to respond to your answer only hit the wrong reply.
    I have tried both of your suggestions and I'm unable to come up with the results I'm looking for I have to be entering something wrong.

    Under general formatting =MOD((TEXT(E4,"00\:00")-TEXT(D4,"00\:00")),1)*24*60<< is giving me a "0".
    I'll figure this thing out one way or another. Thank you for your help.
    Thank You!!!! Finally figured out where i was making my error form this has solved my problem. Thank you so much!!

  19. #19
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Formatting Numarical Values with Custom Formatting

    here are those working
    Attached Files Attached Files

+ 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. convert custom formatting values to text
    By Mathemous in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-29-2013, 08:58 PM
  2. [SOLVED] Custom Formatting
    By nastech in forum Excel General
    Replies: 2
    Last Post: 04-26-2006, 05:45 PM
  3. Replies: 1
    Last Post: 03-10-2006, 11:30 AM
  4. [SOLVED] custom formatting
    By BorisS in forum Excel General
    Replies: 2
    Last Post: 12-12-2005, 05:50 AM
  5. Custom formatting
    By John Knoke in forum Excel General
    Replies: 3
    Last Post: 03-26-2005, 01:06 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