+ Reply to Thread
Results 1 to 4 of 4

Thread: Changing HH:MM AM/PM to military time

  1. #1
    Registered User
    Join Date
    01-08-2009
    Location
    Sombra, Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    Changing HH:MM AM/PM to military time

    How do I do this? Using the simple format to HH:MM:SS does not work. It doesn't do anything. I think the time might be a text string? For example, I want to change 6:07AM to 06:07:00. Any help is appreciated.
    Thanks,

  2. #2
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,770

    Re: Changing HH:MM AM/PM to military time

    Replace "AM" with " AM" (sans quotes) and then format as you like.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    01-08-2009
    Location
    Sombra, Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Changing HH:MM AM/PM to military time

    This did not seem to work. I have attached an example. Also, I want to ensure that this can be simple because I will be running a macro for many lines. Thanks,
    Attached Files Attached Files

  4. #4
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Changing HH:MM AM/PM to military time

    If you want to do this with code then based on your sample file:

    Sub Example()
    With Range(Cells(1, "D"), Cells(Rows.Count, "D").End(xlUp))
        .NumberFormat = "hh:mm:ss"
        .Value = Evaluate("IF(ROW(" & .Address & "),TRIM(REPLACE(" & .Address & ",LEN(" & .Address & ")-1,0,"" "")))")
    End With
    End Sub

+ 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.2.0