Formatting of Time in message box

Kentetsu

Well-known Member
Joined
Jan 22, 2004
Messages
520
Hi all,

So, I've got a message box that will pop up to tell the user what ingredient to add, and how long it will have to mix for. However, the time (which should be displayed as minutes, like 2:00) shows up as 8.333333333333E-2 (or something like that). I've checked the formatting of the cell that I am drawing the info from, and it appears correctly. Not sure how to change the formatting in a message box.

Code:
MsgBox "Your 2nd Ingredient(s) = " & Sheets("Scrap").Range("E15").Value _
    & " And Will Mix for " & Sheets("Scrap").Range("E16").Value & vbCrLf & vbCrLf & _
     "Add The Ingredient(s), THEN Click OK", vbOKOnly

Any advice is greatly appreciated...
 
I'm guessing because strTime is a string variable and TimeValue requires a time or at least numerical variable?

When stepping through the procedure, I can hover over the strTime in the Application.wait line and it shows :02 as I assume it should. I'm going to make a new thread for this question. Thanks again for the assistance...
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
That's still a string representation and not a number, because strTime has been declared as a string variable.
 
Upvote 0
Try:
Code:
Sub M1()

    Dim strMsg      As String
    Dim strTime     As String
    
    strMsg = "Your 2nd Ingredient(s) = @2ING@1@1And will mix for: @TIME@1@1Add the ingredient(s), THEN Click ok"
    
    With Sheets("Scrap")
        
        strTime = Format(.Cells(16, 5), "MM:SS")
        strTime = .Cells(16, 5).Text
        
        strMsg = Replace(strMsg, "@2ING", .Cells(15, 5).Value)
        strMsg = Replace(strMsg, "@TIME", strTime)
        
        MsgBox Replace(strMsg, "@1", vbCrLf), vbOKOnly, "Second Ingredients"
        
        Sheets("Stop").Visible = True
        Sheets("Go").Visible = xlVeryHidden
    
        Application.Wait (Now + TimeValue(.Cells(16, 5)))


        Sheets("Go").Visible = True
        Sheets("Stop").Visible = xlVeryHidden
    End With
     
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top