ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Format problem in displayed userform (https://www.excelbanter.com/excel-worksheet-functions/193095-format-problem-displayed-userform.html)

Anthony

Format problem in displayed userform
 
Hi all,

In sheet 'DATA' cells B12 and I12 are the source data
these are copy/pasted into cells B2 and I12 of 'RESULTS' sheet
all of these cells are formatted as 'Custom hh:mm' however when I place
these values into my userform they are with no format ie 0.42342423154238

Any ideas as to why??

many thanks

Jarek Kujawa[_2_]

Format problem in displayed userform
 
0.42342423154238 stands for 10:09:44

you should (re)format yr values put into userform

with .NumberFormat = "h:mm:ss" for instance

Anthony

Format problem in displayed userform
 
Hi Jarek and thanks for ur reply,

the code in my userform is as follows...

ws.Cells(iRow, 2).Value = Me.txtTime.Value

how do I reformat this so that is is correctly formatted as HH:MM?

"Jarek Kujawa" wrote:

0.42342423154238 stands for 10:09:44

you should (re)format yr values put into userform

with .NumberFormat = "h:mm:ss" for instance


Jarek Kujawa[_2_]

Format problem in displayed userform
 
am not sure but you might try Me.txtTime

or use sth. like

ws.Cells(iRow, 2).Value =
Application.WorksheetFunction.Text(Me.txtTime,"hh: mm")

Dave Peterson

Format problem in displayed userform
 
with ws.cells(irow,2)
.numberformat = "h:mm:ss"
.value = me.txttime.value
end with



Anthony wrote:

Hi Jarek and thanks for ur reply,

the code in my userform is as follows...

ws.Cells(iRow, 2).Value = Me.txtTime.Value

how do I reformat this so that is is correctly formatted as HH:MM?

"Jarek Kujawa" wrote:

0.42342423154238 stands for 10:09:44

you should (re)format yr values put into userform

with .NumberFormat = "h:mm:ss" for instance


--

Dave Peterson

Anthony

Format problem in displayed userform
 
Hi Dave,

Sorry I think I placed the wrong part of the code..

it should have been

frmOldJob.Label18 = Range("B2")

So how do I get this formatted as hh:mm??

"Dave Peterson" wrote:

with ws.cells(irow,2)
.numberformat = "h:mm:ss"
.value = me.txttime.value
end with



Anthony wrote:

Hi Jarek and thanks for ur reply,

the code in my userform is as follows...

ws.Cells(iRow, 2).Value = Me.txtTime.Value

how do I reformat this so that is is correctly formatted as HH:MM?

"Jarek Kujawa" wrote:

0.42342423154238 stands for 10:09:44

you should (re)format yr values put into userform

with .NumberFormat = "h:mm:ss" for instance


--

Dave Peterson


Jarek Kujawa[_2_]

Format problem in displayed userform
 
why not:

frmOldJob.Label18.Caption =
Application.WorksheetFunction.Text((Range("B2"), "hh:mm:ss")


HIH

Anthony

Format problem in displayed userform
 
Hi Jarek,

A slight typo but your suggestion works just great...

Application.WorksheetFunction.Text((Range("B2")), "hh:mm:ss")

Many thanks
"Jarek Kujawa" wrote:

why not:

frmOldJob.Label18.Caption =
Application.WorksheetFunction.Text((Range("B2"), "hh:mm:ss")


HIH


Dave Peterson

Format problem in displayed userform
 
If B2 is already formatted nicely:
frmOldJob.Label18 = Range("B2").Text

or use VBA's own format function:
frmOldJob.Label18 = format(Range("B2").value, "h:mm:ss")



Anthony wrote:

Hi Dave,

Sorry I think I placed the wrong part of the code..

it should have been

frmOldJob.Label18 = Range("B2")

So how do I get this formatted as hh:mm??

"Dave Peterson" wrote:

with ws.cells(irow,2)
.numberformat = "h:mm:ss"
.value = me.txttime.value
end with



Anthony wrote:

Hi Jarek and thanks for ur reply,

the code in my userform is as follows...

ws.Cells(iRow, 2).Value = Me.txtTime.Value

how do I reformat this so that is is correctly formatted as HH:MM?

"Jarek Kujawa" wrote:

0.42342423154238 stands for 10:09:44

you should (re)format yr values put into userform

with .NumberFormat = "h:mm:ss" for instance


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 12:00 AM.

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