Excel's so-called custom number formats are actually just configurable from a pretty good but finite palette of options. I want a format that (I'm pretty sure) can't be made from the "custom" formats dialog, and therefore not from the .NumberFormat method either.
The format I want is a minimum number of significant figures, but not fewer than zero decimal places. Yes, I could use scientific notation, but there are time that just doesn't look right. For example:
<tbody>
</tbody>The right column is pi, with the decimal point shifted according to the left column, just to have an example to show. The right column is formatted as enough decimal places to provide at least three significant figures and more when the number is at least 1000.
Sure, I could write a little code to set the number of decimal places cell by cell (which is what I did by hand to generate the example) but I'd like to apply a brand new truly custom format to the range. Is there a way to code new formats like this? I'm not asking for the code, as I'm sure I can do that if someone can give me the key starting point, i.e. how to apply such code to all cells in a range as a new format, rather than having to run a macro explicitly whenever the cell values change.
The format I want is a minimum number of significant figures, but not fewer than zero decimal places. Yes, I could use scientific notation, but there are time that just doesn't look right. For example:
-3 | 3142 |
-2 | 314 |
-1 | 31.4 |
3.14 | |
1 | 0.314 |
2 | 0.0314 |
3 | 0.00314 |
4 | 0.000314 |
5 | 0.0000314 |
<tbody>
</tbody>
Sure, I could write a little code to set the number of decimal places cell by cell (which is what I did by hand to generate the example) but I'd like to apply a brand new truly custom format to the range. Is there a way to code new formats like this? I'm not asking for the code, as I'm sure I can do that if someone can give me the key starting point, i.e. how to apply such code to all cells in a range as a new format, rather than having to run a macro explicitly whenever the cell values change.