ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   military time formatting... (https://www.excelbanter.com/excel-programming/367720-military-time-formatting.html)

sbowman

military time formatting...
 
I have a create, edit, delete program I've done in excel and I need to
pass a start time and end time value back and forth from cells to my
userform. I've tried using military format HHMM and 00\:00. It works
fine passing the time value from the userform to the cell, but not the
other way!! Here's my variable (dim as date):

BeforeEditStartTime = Format(Range("F" & rowindex).Text, "HHMM")

The cell this value is entered in is in custom HHMM format. When I pass
it back to the program it reads (for example) 1200 as 0000 or 12:00:00
AM.

HELP!!


Jim Thomlinson

military time formatting...
 
Try changing .Text to .Value. The format function takes a date (or number)
and converts it to a text string with a specific format applied. What you are
doing is passing in a string which format can't do too much with...
--
HTH...

Jim Thomlinson


"sbowman" wrote:

I have a create, edit, delete program I've done in excel and I need to
pass a start time and end time value back and forth from cells to my
userform. I've tried using military format HHMM and 00\:00. It works
fine passing the time value from the userform to the cell, but not the
other way!! Here's my variable (dim as date):

BeforeEditStartTime = Format(Range("F" & rowindex).Text, "HHMM")

The cell this value is entered in is in custom HHMM format. When I pass
it back to the program it reads (for example) 1200 as 0000 or 12:00:00
AM.

HELP!!



sbowman

military time formatting...
 
nevermind I fixed it by formatting the cells as text instead of
general. I'm not doing any time calculations, so it's fine to have it
as text instead of a date.

Thanks anyway...
Shelley

Jim Thomlinson wrote:
Try changing .Text to .Value. The format function takes a date (or number)
and converts it to a text string with a specific format applied. What you are
doing is passing in a string which format can't do too much with...
--
HTH...

Jim Thomlinson


"sbowman" wrote:

I have a create, edit, delete program I've done in excel and I need to
pass a start time and end time value back and forth from cells to my
userform. I've tried using military format HHMM and 00\:00. It works
fine passing the time value from the userform to the cell, but not the
other way!! Here's my variable (dim as date):

BeforeEditStartTime = Format(Range("F" & rowindex).Text, "HHMM")

The cell this value is entered in is in custom HHMM format. When I pass
it back to the program it reads (for example) 1200 as 0000 or 12:00:00
AM.

HELP!!





All times are GMT +1. The time now is 05:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com