Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Is there a way to enter military time in a cell (1700), and have the result formatted in hh:mm (5:00 PM)?

Posted on 2016-08-29
11
Medium Priority
?
190 Views
Last Modified: 2016-08-29
Is there a way to enter military time in a cell (for ex, 1700), and have the result formatted in hh:mm (for ex, 5:00 PM)?

Thanks!
0
Comment
Question by:Tim Jackoboice
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 23

Expert Comment

by:yo_bee
ID: 41775690
By default if you set the cell or column to format as Time 5:00 PM and enter 17:00 in the cell you will see it as 5:00 PM

Is that what you are looking for or are you looking for 1700 to be converted to Standard US TIME?
0
 

Author Comment

by:Tim Jackoboice
ID: 41775691
What I'm really trying to do is just enter regular time without the colon, for a large Excel sheet for payroll every week.

I thought using military time would work, as it at saved a couple steps entering 17:00 and then having the cell formatted so the result after typing it into the cell was 5:00 PM. (I obviously just using the "1:30 PM" format for the cells.)

Is there an easier way so I can just enter time without using the : (colon)?  It's a pain entering dozens and dozens of clock-in and clock-out times, and always having to shift and click to enter a colon into every time I input. Thanks.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41775693
Can you use a helper column?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:yo_bee
ID: 41775694
you can do something like this.
Format the column to Time 5:00 PM and enter this formula in
=TIMEVALUE((CONCAT(LEFT(F1,2),":",MID(F1,3,2))))

Open in new window


F1 is where you enter you 1700 and G1 is where there formula is entered.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41775698
Or, you can use an event handler macro like this. This works for column 3. You can change this in the second row

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 3 Then
        If Len(Target) = 4 And IsNumeric(Target) Then
            Target.Value = Left(Target, 2) & ":" & Right(Target, 2)
        End If
    End If
End Sub
0
 

Author Comment

by:Tim Jackoboice
ID: 41775701
Unfortunately, I can't use a helper cell....
0
 

Author Comment

by:Tim Jackoboice
ID: 41775703
Saqib ... I'm a novice at macros and VBA. How exactly do I enter in what you suggested so this will work for me?
0
 

Author Comment

by:Tim Jackoboice
ID: 41775704
I am entering times into cells A7:O34 in one particular tab of a large Excel workbook.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41775705
Right-click on the sheet tab name
Select View code
Paste the given code in the VBA window
Close the VBA window
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 total points
ID: 41775706
For the specified range

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A7:O34")) Is Nothing Then
        If Len(Target) = 4 And IsNumeric(Target) Then
            Target.Value = Left(Target, 2) & ":" & Right(Target, 2)
        End If
    End If
End Sub
0
 

Author Closing Comment

by:Tim Jackoboice
ID: 41775711
Got it. Perfect! It works ... thank you very much!!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question