![]() |
Entering the time in a cell
How do it enter in a single digit for time but have it displayed at full
time. For example if I type in the number 8 how to I get it to display 8:00? |
Entering the time in a cell
It won't be a true time value, but you can get the appearance by formatting
cell: 0":00" -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "Hezzy" wrote: How do it enter in a single digit for time but have it displayed at full time. For example if I type in the number 8 how to I get it to display 8:00? |
Entering the time in a cell
There is nothing built in but with a little VBA as described here it is
possible... http://www.cpearson.com/excel/DateTimeEntry.htm -- HTH... Jim Thomlinson "Hezzy" wrote: How do it enter in a single digit for time but have it displayed at full time. For example if I type in the number 8 how to I get it to display 8:00? |
Entering the time in a cell
Hi,
Here is some rather more complex code which you can cut down to what you need: Private Sub Worksheet_Change(ByVal Target As Range) Dim I As Integer Set isect = Application.Intersect(Target, Range("Time")) If isect Is Nothing Then Exit Sub 'not inside the desired range If Target.Count 1 Then Exit Sub 'more than one cell selected Application.EnableEvents = False 'Numeric entries If Target = 1 Then If Len(Target) = 1 Then Target = Target & " AM" ElseIf Len(Target) = 2 Then If Target <= 12 Then Target = Target & " AM" Else Target = Target - 12 & " PM" End If ElseIf Len(Target) = 3 Then Target = Left(Target, 1) & ":" & Right(Target, 2) Application.EnableEvents = True Exit Sub ElseIf Len(Target) = 4 Then Target = Format(Left(Target, 2) & ":" & Right(Target, 2), "HH:MM AM/PM") Application.EnableEvents = True Exit Sub Else MsgBox "That entry is not a legal time." Target.ClearContents Application.EnableEvents = True Exit Sub End If End If End If Application.EnableEvents = True End Sub -- If this helps, please click the Yes button. Cheers, Shane Devenshire "Hezzy" wrote: How do it enter in a single digit for time but have it displayed at full time. For example if I type in the number 8 how to I get it to display 8:00? |
All times are GMT +1. The time now is 05:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com