Format number in Msgbox

hoanganhdl

New Member
Joined
Dec 9, 2016
Messages
2
Code:
Sub test()


    Application.DecimalSeparator = ","
    Application.ThousandsSeparator = "."
    Application.UseSystemSeparators = False


    MsgBox Format("123456", "#,##0")


Exit Sub

I want result is 123.456 but it is 123,456.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Code:
Sub test()
Dim sNum As String


    sNum = Format("123456.4", "#"".""##0")


    MsgBox sNum


End Sub

It comes thru as a String but it works.
 
Upvote 0
Oh thanks, I'm going to have a look into this.
:)
Type the function name Format in the Immediate Window (press CTRL+G if you don't see it) inside the VB editor and then, with the text cursor next to or inside the word, press the F1 key to bring up the help file for that function... scroll to the bottom of the help page and look at the next-to-last entry in the displayed table. You might also find this link of interest...

https://en.wikipedia.org/wiki/Escape_character
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,521
Messages
6,125,308
Members
449,218
Latest member
Excel Master

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