I want to format a number as M(million), B(Billion) or K(thousand) dynamically based on the value in the cell. I tried (but this does not work):
[>1000000000]0,,,"B";[>1000000]0,,"M";[>1000]0,"K";0”
If I give any two conditions it works, eg:
[>1000000000]0,,,"B";[>1000000]0,,"M";0
or
[>1000000]0,,"M";[>1000]0,"K";0 )
Refer : https://www.sumproduct.com/thought/multiple-number-formatting.html
This article (third example) mentions that only two conditions in the formatting statement are allowed:
And as mentioned in the Excel 2010 help:
As an intermediate solution you could use the following VBA function I have written:
Which results in:
First column is the original number, 2nd with the number formatting you proposed, and third with the VBA function
FormatNumber
. Note that the results ofFormatNumber
are Strings, so you cannot use them to calculate.