Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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
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
Display decimals in a msgbox Don Guillett Excel Programming 0 December 7th 06 03:06 PM
How to display remaining txt file which overflowed MsgBox display? EagleOne Excel Discussion (Misc queries) 1 November 2nd 06 01:10 PM
display msgbox in order or one after the other harpscardiff[_5_] Excel Programming 1 October 20th 05 04:40 PM
MsgBox Display Michael S. Excel Programming 2 June 16th 05 10:55 PM
Display of $ in Msgbox David Excel Programming 2 September 8th 04 09:38 AM


All times are GMT +1. The time now is 09:06 PM.

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

About Us

"It's about Microsoft Excel"