In Excel format number with optional decimal places
Posted
by
Ray
on Super User
See other posts from Super User
or by Ray
Published on 2008-08-22T04:31:59Z
Indexed on
2012/06/17
15:19 UTC
Read the original article
Hit count: 209
microsoft-excel
|formatting
Simple: I have numbers in cells in excel. I want the numbers formatted so that if they have decimal places they show to a maximum of 2DP and if they have no decimal places it doesn't show any.
For example.
- 15 should be formatted as 15 NOT 15.00
- 14.3453453 should be formatted as 14.35
- 12.1 should be formatted as 12.1
- 0 should be formatted as 0
The closest custom format code I've come up with is 0.##. Unfortunately this formats 15.00 as 15. (note the extra decimal place).
Edit: To further complicate the issues, the spreadsheet is a result of an export from SQL Server Reporting Services. So no macros are possible. Oh well, it looks like 0.## is my best bet, and they can just live with the extra period.
© Super User or respective owner