How does one avoid differences in users keyboard language when using the Format command(VBA)?

Mescoman

New Member
Joined
Oct 27, 2021
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hey hey people.

I need to use the Format function to change some raw numbers like "123456789.123456789" to either be "123,456,789" or "123.456.789", depending on the language a user selects when activating my macro. I found some code online from Formatting Numbers in Excel VBA - Automate Excel that claims that the code
SQL:
[TABLE]
[TR]
[TD][/TD]

[TD]MsgBox Format(1234567.89, "#,##0.00")[/TD]
[/TR]
[/TABLE]
will print " 1,234,567.89 ", but for me (I assume its because I am using a Spanish keyboard) it swaps the dots and commas around. But then when I change my keyboard to English (my excel commands are all shown in English) it still prints the Spanish version of "1.234.567,89" (maybe its since the document itself was originally written in Spanish?)

So I have a couple of questions:

- If someone else runs my macro on their computer, will it change how this may be printed? I need to avoid this since the macro will generate a report in a specific language, and the people generating the reports computer language might not match the language they want the report to be in. I tried changing the language to English and it still prints the message with the Spanish " 1.234.567,89 ", despite my excel and my computer being in English

- In general, how does the Format function actually work? Most importantly, how could I insist on the English/Spanish format of commas then decimals/decimals then commas irregardless of the language? This way I could avoid the headache of having to keep track of what language format excel will decide to follow with the code I found on that website.

Sorry to cram so many questions into one, but all of these are things I would like to understand better so I can better use Format later down the line: Im going to have to use lots of different English/Spanish differences while formating other numbers differently (I may want 2 significant figures later, or 3 decimal places say)
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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