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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

friel300

Board Regular
Joined
Jan 22, 2008
Messages
69
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

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
38,150
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Never seen that before what does that slash mean?
In some script languages, it is called an "escape character" and it means treat the next character as just a character without any special meaning; hence, \. will be interpreted as a period and not a decimal point.
 
Upvote 0

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
38,150
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
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,191,165
Messages
5,985,036
Members
439,935
Latest member
Monty238

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
Top