Msg Box including a variable.

alexaronson

Active Member
Joined
Sep 30, 2005
Messages
314
Hello,

I want to make a message box that says the following:

"The system took 25 seconds to process."

Where the 25 is a variable.

I have the following code already.
Sub Time()
Dim t as Double, x
t = Timer
For x = 1 to 10
Blah Blah Blah
next x
MsgBox Timer - t
End Sub

As the code stands, I only get the 25 in the message box. How can I add the text?

Thanks,
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Code:
MsgBox "The system took " & Timer-t & "seconds to process."
Are you sure "timer-t" is correct?

lenze
 
Upvote 0
Any idea on how I can truncate the timer output to 4 decimal places?

I am getting results of 0.45093593 seconds.

thanks again for the help!

-Alex
 
Upvote 0
Try

Code:
MsgBox "The system took " & Format(Timer - t, "0.0000") & "seconds to process."
 
Upvote 0

Forum statistics

Threads
1,215,470
Messages
6,124,992
Members
449,201
Latest member
Lunzwe73

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