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
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)
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]
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)