Samuel Green80 said:Hey there..
Can someone explain what kind of formatting I should use to round a number in a cell to two decimal places, but if the second decimal is zero, it rounds to one, and if both decimals are zero, it just displays the whole number without a decimal point? Here’s an example if nobody understands me..
My custom format is currently " 0.## ". So 2.67 shows up as 2.67, 2.60 shows up as 2.6, but 2.00 shows up as 2. . What I actually want is for 2.00 to show up as 2 (meaning, no decimal point at all)
I don't know how to handle this via formatting, but I do know how to fix it without using formats at all—just by using a formula. You can then eventually copy and paste them (paste special - values) into a new Excel sheet if having two columns bothers you. Whether that's a satisfying enough solution is anyone's guess. :not_sure:
Here’s how I pictured it: you have your set values in column A, which could have infinite decimals, but you want Excel to display a whole number if it's an integer; otherwise, let it display the number with two decimals (in my case, the order of conditions in the formula is reversed). You just copy this formula into column B:
=IF((A1-INT(A1))<>0,ROUND(A1,2),INT(A1))
The formula works like this: if the difference between the given number and its integer value is anything other than zero, Excel will display that number rounded to two decimals; otherwise, it will just give you the integer.
The downside to this formula is that you lose some precision. For instance, if you have the number 2.656 and tell it to round to two decimals, Excel might end up showing 2.65 when it really should be 2.66. But hey, if you need to solve that too, it's not impossible...