PDA

View Full Version : [SOLVED:] Time format problem



u25103
03-11-2008, 08:02 AM
:think: Hi (again)

This is my problem. I want to have these columns (text) i time format. I've tryed varius vba cod but nothing works.

I've tried "find and replace" : with . (I use "." as time format)
but i allso vant military time and when a replace the ":"

The correct time (format) I want looks like this:
04.56, 04.59, etc
10.10, 10.10


4:56 4:59 4:59 6:44 6:44 6:44 7:40 7:40 7:40 9:52 9:52 9:5210.1010.1010.1011.1011.1011.16 5:44 5:47 5:47 7:55 7:55 7:55 8:10 8:10 8:10 9:10 9:10 9:10 9:50 9:50 9:5012.5012.5012.5013.1013.1013.1014.1014.1014.16 8:05 8:05 8:05 9:40 9:40 9:40 9:55 9:55 9:5512.1012.1012.10


(sorry, before I submited this the times above where nice columns. I'll vill used columns A,B,D,D)

I hope there is someone out there who is willing to :help me.
Thanks

Charlize
03-11-2008, 08:15 AM
Sub Text_Hour_To_Decimal_Hour()
Dim vitem As Range
Dim htest As Date
For Each vitem In Application.InputBox("Select range", "Select range", Type:=8)
htest = vitem.Value
vitem.NumberFormat = "h.mm"
vitem.Value = htest
Next vitem
End Sub
Charlize

RonMcK
03-11-2008, 11:04 AM
:The correct time (format) I want looks like this:
04.56, 04.59, etc
10.10, 10.10

:
Sub Text_Hour_To_Decimal_Hour()
Dim vitem As Range
Dim htest As Date
For Each vitem In Application.InputBox("Select range", "Select range", Type:=8)
htest = vitem.Value
vitem.NumberFormat = "h.mm"
vitem.Value = htest
Next vitem
End Sub

Charlize,

Will the following work better than the highlighted line, above, given that OP wants a 2.2 time format?

vitem.NumberFormat = "hh.mm"
Thanks,

Charlize
03-11-2008, 02:06 PM
Charlize,

Will the following work better than the highlighted line, above, given that OP wants a 2.2 time format?

vitem.NumberFormat = "hh.mm"
Thanks,It probably could be ...

Charlize