+ Reply to Thread
Results 1 to 4 of 4

time format, if user enters time without colon, insert for them

  1. #1
    Registered User
    Join Date
    06-15-2012
    Location
    Baltimore, MD
    MS-Off Ver
    Excel 2010
    Posts
    68

    time format, if user enters time without colon, insert for them

    I'm looking for a formula that adds a colon to military time if the user hasn't entered one.

    So B1 would have a formula that if A1 = 1113, B1 = 11:13, and if A1 = 11:13, B1 = 11:13

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: time format, if user enters time without colon, insert for them

    try this...

    =IF(A1>1,(LEFT(A1,2)&":"&RIGHT(A1,2))*1,A1)

    But you may want to look at using data validation to make sure they enter the data correctly in the 1st place?
    You could use "decimal" <1
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    06-15-2012
    Location
    Baltimore, MD
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: time format, if user enters time without colon, insert for them

    Well your formula worked perfect but your alternative was even better. Went with the data validation. Thanks!

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: time format, if user enters time without colon, insert for them

    Happy to help, and its always better to do it right, rather than figure out how to fix it

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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