Does anyone have any vb.net or vba code that will format excel values or a range of cells to have comma for 100s, 1000s,10000s etc.. and 2 decimal places only.
i.e. 10,256.45
With a reference to the range:
rng.NumberFormat = "#,##0.00"
The current selection is also a range, so if you want it to work with the selection, just use:
Selection.NumberFormat = "#,##0.00"
If you don't need a specific custom formatting you can use Excel styles:
allRange.Style = "Comma"; // 1234.5678 -> 1,234.56
// or
allRange.Style = "Comma [0]"; // 1234.5678 -> 1,234
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With