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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
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,213,565
Messages
6,114,337
Members
448,568
Latest member
Honeymonster123

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