Formatting % in vbea messagebox

already

Board Regular
Joined
Nov 11, 2008
Messages
179
Hi

I have to put the results of a percent calculation (A3) in a message box in format '00.00 %'

I use the following code but I can't format the decimal places to only 2 digits

Worksheets("Sheet1").Range("A3") & Format(" %", "0.00")

Thanks in advance for your help.

Kind regards

Al
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try this:

Rich (BB code):
MsgBox WorksheetFunction.Text(Worksheets("Sheet1").Range("A3"), "00.00%")
 
Last edited:
Upvote 0
Try this:

Rich (BB code):
MsgBox WorksheetFunction.Text(Worksheets("Sheet1").Range("A3"), "00.00%")
No need to call out to the worksheet's TEXT function, you can do that using VB's built-in Format function...

Rich (BB code):
MsgBox Format(Worksheets("Sheet1").Range("A3"), "0.00%")
 
Upvote 0
No need to call out to the worksheet's TEXT function, you can do that using VB's built-in Format function...

Thanks, Rick. With so many function commands available, I just used the first function I could think of that worked in my test macro. I'll try to keep the VBA Format function in mind next time.
 
Upvote 0
Thanks, Rick. With so many function commands available, I just used the first function I could think of that worked in my test macro. I'll try to keep the VBA Format function in mind next time.
Just keep in mind that Format and TEXT are similar, but nowhere near identical... there are major differences between them, but in this simple case (of a percentage format) they produce the same result.
 
Upvote 0

Forum statistics

Threads
1,215,133
Messages
6,123,233
Members
449,092
Latest member
SCleaveland

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