Set standard number format with thousand separator, 2 decimals and minus sign for negative numbers using VBA?

user1283776

I've seen the question asked before on stackoverflow, how to get normal number format with thousand separator and 2 decimals. The answer was to set:

    rng.NumberFormat = "##0.00"

But this is incomplete, because, at least on my computer, I don't get any space separator between millions and thousands. So I have changed that to:

    rng.NumberFormat = "### ### ##0.00"

But this is again incomplete, because for some reason negative numbers were formatted to look like they have a space between the minus sign and the number. See below:

- 12.4

So, there are some things left to do to arrive at Excels "built-in" "format as number" formats. Additionally the formatting that I apply though VBA is described as Custom by Excel.

Is there any way to set the format to be the standard built in format as number with thousand separators, 2 decimals and minus signs for negative numbers?

I'm looking for something like:

    rng.NumberFormat = "Number, 2, minus"
simon at rcl
rng.NumberFormat = "# ##0.00:-# ##0.00"

You put the format for positive numbers before : and the format for negative after. You don't need to put hundreds of # signs in the format, just enough to show what the 1000's separator is.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Format integer number with . as thousand separator and no decimals

From Dev

Format number with space as thousand separator

From Dev

Format number with space as thousand separator

From Dev

String Number format with "/" for thousand separator

From Dev

How to format number with "." as thousand separator, and "," as decimal separator?

From Dev

Format a bootstrap table with dollar sign and thousand separator

From Dev

ionic +number format trouble based on the thousand separator

From Dev

How do I stop Excel from rounding numbers when format has been set to number and to 2 decimals?

From Dev

In Google Visualization number format when having negative money how can I have the minus sign before the dollar sign

From Dev

How do I set the number of decimals in a Numbers cell using AppleScript?

From Dev

Format a number to always have a sign and decimal separator

From Dev

Number format is giving + sign for negative decimal number

From Dev

regex for multiple formats decimals and thousand separator

From Dev

Regex valid numbers with thousand separator

From Dev

Regex valid numbers with thousand separator

From Dev

Minus sign removed using number formatting with jQuery

From Dev

remove thousand separator of number in CSV (batch command, using JREPL)

From Dev

Format number in R with both comma thousands separator and specified decimals

From Dev

python string format with negative sign for negative number, but space for positive number

From Dev

Format to show positive or negative sign of a number in java

From Dev

Set global thousand separator on knitr

From Dev

Python regex for number with or without decimals using a dot or comma as separator?

From Dev

Using math for negative minus negative

From Dev

How to calculate numbers with dot thousand separator in javascript

From Dev

How to eliminate the extra minus sign when rounding negative numbers towards zero in numpy?

From Dev

d3.format thousand separator on variables?

From Dev

ExtJS 6 thousand separator in number field

From Dev

Is it possible to print a number formatted with thousand separator in Rust?

From Dev

Adding thousand separator while printing a number

Related Related

  1. 1

    Format integer number with . as thousand separator and no decimals

  2. 2

    Format number with space as thousand separator

  3. 3

    Format number with space as thousand separator

  4. 4

    String Number format with "/" for thousand separator

  5. 5

    How to format number with "." as thousand separator, and "," as decimal separator?

  6. 6

    Format a bootstrap table with dollar sign and thousand separator

  7. 7

    ionic +number format trouble based on the thousand separator

  8. 8

    How do I stop Excel from rounding numbers when format has been set to number and to 2 decimals?

  9. 9

    In Google Visualization number format when having negative money how can I have the minus sign before the dollar sign

  10. 10

    How do I set the number of decimals in a Numbers cell using AppleScript?

  11. 11

    Format a number to always have a sign and decimal separator

  12. 12

    Number format is giving + sign for negative decimal number

  13. 13

    regex for multiple formats decimals and thousand separator

  14. 14

    Regex valid numbers with thousand separator

  15. 15

    Regex valid numbers with thousand separator

  16. 16

    Minus sign removed using number formatting with jQuery

  17. 17

    remove thousand separator of number in CSV (batch command, using JREPL)

  18. 18

    Format number in R with both comma thousands separator and specified decimals

  19. 19

    python string format with negative sign for negative number, but space for positive number

  20. 20

    Format to show positive or negative sign of a number in java

  21. 21

    Set global thousand separator on knitr

  22. 22

    Python regex for number with or without decimals using a dot or comma as separator?

  23. 23

    Using math for negative minus negative

  24. 24

    How to calculate numbers with dot thousand separator in javascript

  25. 25

    How to eliminate the extra minus sign when rounding negative numbers towards zero in numpy?

  26. 26

    d3.format thousand separator on variables?

  27. 27

    ExtJS 6 thousand separator in number field

  28. 28

    Is it possible to print a number formatted with thousand separator in Rust?

  29. 29

    Adding thousand separator while printing a number

HotTag

Archive