Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
MsgBox to display [hh]:mm
Trying to finish up the macro with this message box
wtime=ActiveCell.Value MsgBox("You worked for " & wtime & "Hrs:Min") Cell where the value is taken from contains formula, is formatted as [hh]:mm and is displayed right. But when I try to use the value in the message box, I get something like 9.12435E-3. It's gotta be simple but I can't figure it out. Thank you |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
MsgBox to display [hh]:mm
Try this
wtime = ActiveCell.Value MsgBox ("You worked for " & Format(wtime, "hh:mm") & " Hrs:Min") The cell's format isn't part of the value you are storing in wtime, so you have to format it in the messagebox also. Hope this helps, Hutch "learner" wrote: Trying to finish up the macro with this message box wtime=ActiveCell.Value MsgBox("You worked for " & wtime & "Hrs:Min") Cell where the value is taken from contains formula, is formatted as [hh]:mm and is displayed right. But when I try to use the value in the message box, I get something like 9.12435E-3. It's gotta be simple but I can't figure it out. Thank you |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
MsgBox to display [hh]:mm
Hi
You have to format the timevalue: wtime = ActiveCell.Value MsgBox ("You worked for " & Format(wtime, "hh:mm") & " Hrs:Min") Regards, Per On 23 Okt., 21:05, learner wrote: Trying to finish up the macro with this message box wtime=ActiveCell.Value MsgBox("You worked for " & wtime & "Hrs:Min") Cell where the value is taken from contains formula, is formatted as [hh]:mm and is displayed right. But when I try to use the value in the message box, I get something like 9.12435E-3. It's gotta be simple but I can't figure it out. Thank you |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
MsgBox to display [hh]:mm
Hi,
Try this hrs = WorksheetFunction.Text(ActiveCell.Value, "[hh]") & " Hours " Mins = Minute(ActiveCell.Value) & " Mins" MsgBox "You worked for " & hrs & Mins Mike "learner" wrote: Trying to finish up the macro with this message box wtime=ActiveCell.Value MsgBox("You worked for " & wtime & "Hrs:Min") Cell where the value is taken from contains formula, is formatted as [hh]:mm and is displayed right. But when I try to use the value in the message box, I get something like 9.12435E-3. It's gotta be simple but I can't figure it out. Thank you |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
MsgBox to display [hh]:mm
Thanks Tom, works perfect.
"Tom Hutchins" wrote: Try this wtime = ActiveCell.Value MsgBox ("You worked for " & Format(wtime, "hh:mm") & " Hrs:Min") The cell's format isn't part of the value you are storing in wtime, so you have to format it in the messagebox also. Hope this helps, Hutch "learner" wrote: Trying to finish up the macro with this message box wtime=ActiveCell.Value MsgBox("You worked for " & wtime & "Hrs:Min") Cell where the value is taken from contains formula, is formatted as [hh]:mm and is displayed right. But when I try to use the value in the message box, I get something like 9.12435E-3. It's gotta be simple but I can't figure it out. Thank you |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
MsgBox to display [hh]:mm
I appreciate Mike,
It worked too and it now looks better than what I had in mind. "Mike H" wrote: Hi, Try this hrs = WorksheetFunction.Text(ActiveCell.Value, "[hh]") & " Hours " Mins = Minute(ActiveCell.Value) & " Mins" MsgBox "You worked for " & hrs & Mins Mike "learner" wrote: Trying to finish up the macro with this message box wtime=ActiveCell.Value MsgBox("You worked for " & wtime & "Hrs:Min") Cell where the value is taken from contains formula, is formatted as [hh]:mm and is displayed right. But when I try to use the value in the message box, I get something like 9.12435E-3. It's gotta be simple but I can't figure it out. Thank you |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
MsgBox to display [hh]:mm
You will also want to use Mike's WorksheetFunction.Text method instead of
the Format function that others posted **if** there is any chance that the total hours could be more than 24... the Format function does not support the [hh] argument (that is, you can't use the square brackets with it) and will "wrap" the hours back to 0 at the 24-hour mark. -- Rick (MVP - Excel) "learner" wrote in message ... I appreciate Mike, It worked too and it now looks better than what I had in mind. "Mike H" wrote: Hi, Try this hrs = WorksheetFunction.Text(ActiveCell.Value, "[hh]") & " Hours " Mins = Minute(ActiveCell.Value) & " Mins" MsgBox "You worked for " & hrs & Mins Mike "learner" wrote: Trying to finish up the macro with this message box wtime=ActiveCell.Value MsgBox("You worked for " & wtime & "Hrs:Min") Cell where the value is taken from contains formula, is formatted as [hh]:mm and is displayed right. But when I try to use the value in the message box, I get something like 9.12435E-3. It's gotta be simple but I can't figure it out. Thank you |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Display decimals in a msgbox | Excel Programming | |||
How to display remaining txt file which overflowed MsgBox display? | Excel Discussion (Misc queries) | |||
display msgbox in order or one after the other | Excel Programming | |||
MsgBox Display | Excel Programming | |||
Display of $ in Msgbox | Excel Programming |