#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Military Time Issue


I have created a project that finds the difference between multiple
times and then adds up the differences. All of which is formatted in
military time and some times utilize two different days.

I would (actually the boss) would like to have the times entered
without the use of ":" and just straight "hhmm" format, to make it
easier to enter.

I changed the format to reflect hhmm, but when I enter the time it
displays in the cell as "0000" and then in the fz box as a date and
time that is nowhere close to what was entered. Then it does not do
the calculations correctly in the next cells.

If the data is already entered and I change the format to hhmm, it
works just fine, but it won't work to be able to enter it.

Any help would be appreciated, I think I am completely lost with this
one.

See attachment for example of what is being done.


+-------------------------------------------------------------------+
|Filename: time example.doc |
|Download: http://www.excelforum.com/attachment.php?postid=5189 |
+-------------------------------------------------------------------+

--
vldavis809
------------------------------------------------------------------------
vldavis809's Profile: http://www.excelforum.com/member.php...o&userid=36146
View this thread: http://www.excelforum.com/showthread...hreadid=571361

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Military Time Issue

Copy the code below, right-click on the sheet tab, ans paste the code in the window that appears.
It will work on any cell that is formatted for hhmm.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Not IsNumeric(Target.Value) Then Exit Sub
On Error GoTo ErrHandler:
If Target.NumberFormat = "hhmm" Then
Application.EnableEvents = False
Target.Value = Int(Target.Value / 100) / 24 + (Target.Value Mod 100) / 1440
Application.EnableEvents = True
End If

ErrHandler:
Application.EnableEvents = True
End Sub



"vldavis809" wrote in message
...

I have created a project that finds the difference between multiple
times and then adds up the differences. All of which is formatted in
military time and some times utilize two different days.

I would (actually the boss) would like to have the times entered
without the use of ":" and just straight "hhmm" format, to make it
easier to enter.

I changed the format to reflect hhmm, but when I enter the time it
displays in the cell as "0000" and then in the fz box as a date and
time that is nowhere close to what was entered. Then it does not do
the calculations correctly in the next cells.

If the data is already entered and I change the format to hhmm, it
works just fine, but it won't work to be able to enter it.

Any help would be appreciated, I think I am completely lost with this
one.

See attachment for example of what is being done.


+-------------------------------------------------------------------+
|Filename: time example.doc |
|Download: http://www.excelforum.com/attachment.php?postid=5189 |
+-------------------------------------------------------------------+

--
vldavis809
------------------------------------------------------------------------
vldavis809's Profile: http://www.excelforum.com/member.php...o&userid=36146
View this thread: http://www.excelforum.com/showthread...hreadid=571361



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Military Time Issue


Take a look at http://www.mrexcel.com/tip029.shtml

This uses a change_event macro, which grabs your input of 1234 and
inserts the colon for you.

THe instructions on this page are fairly good.

Regards
Mike


--
Mikeopolo
------------------------------------------------------------------------
Mikeopolo's Profile: http://www.excelforum.com/member.php...o&userid=18570
View this thread: http://www.excelforum.com/showthread...hreadid=571361

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Military Time Issue


Bernie,

That worked great!!!

I have one question, if I enter data and decide it was incorrect, then
delete the data, it now defaults to "0000" and reads as 1200 midnite. I
have to delete the entire row to be able to remove the data. I know I
can overwrite it, but there may be a time where there is a keystroke
error.

It has to remain blank because there is a formula that reads the
information somewhere else to calculate certain time frames.

Any ideas?


--
vldavis809
------------------------------------------------------------------------
vldavis809's Profile: http://www.excelforum.com/member.php...o&userid=36146
View this thread: http://www.excelforum.com/showthread...hreadid=571361

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Military Time Issue

Select the cell and press delete - don't overwrite it with a zero....

HTH,
Bernie
MS Excel MVP


"vldavis809" wrote in message
...

Bernie,

That worked great!!!

I have one question, if I enter data and decide it was incorrect, then
delete the data, it now defaults to "0000" and reads as 1200 midnite. I
have to delete the entire row to be able to remove the data. I know I
can overwrite it, but there may be a time where there is a keystroke
error.

It has to remain blank because there is a formula that reads the
information somewhere else to calculate certain time frames.

Any ideas?


--
vldavis809
------------------------------------------------------------------------
vldavis809's Profile: http://www.excelforum.com/member.php...o&userid=36146
View this thread: http://www.excelforum.com/showthread...hreadid=571361





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Military Time Issue

Sorry, I had changed the code that I gave you. You need to add the line

If Target.Value = "" Then Exit Sub

at the top...

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Select the cell and press delete - don't overwrite it with a zero....

HTH,
Bernie
MS Excel MVP


"vldavis809" wrote in message
...

Bernie,

That worked great!!!

I have one question, if I enter data and decide it was incorrect, then
delete the data, it now defaults to "0000" and reads as 1200 midnite. I
have to delete the entire row to be able to remove the data. I know I
can overwrite it, but there may be a time where there is a keystroke
error.

It has to remain blank because there is a formula that reads the
information somewhere else to calculate certain time frames.

Any ideas?


--
vldavis809
------------------------------------------------------------------------
vldavis809's Profile: http://www.excelforum.com/member.php...o&userid=36146
View this thread: http://www.excelforum.com/showthread...hreadid=571361





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to subtract military time i.e. 1503-1455 or 3:03pm-2:55pm? jetmendoza Excel Discussion (Misc queries) 9 July 31st 07 08:52 PM
convert military time to regular hours Kathy Excel Worksheet Functions 1 April 25th 06 01:20 PM
getting military time format within excel dgarrison Excel Discussion (Misc queries) 3 December 25th 05 10:47 PM
simple time sheet issue hello Excel Discussion (Misc queries) 7 September 14th 05 03:10 PM
in excel totaling weekly hours military time mel Excel Worksheet Functions 1 January 17th 05 04:24 PM


All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"