0

I want to format a number with two decimals unless it's 0. Can I do this?

123.93
 23.00
144.34
     0
  2.38

4 Answers 4

5

This works great:

Go to format cells and select custom. Then paste this 0.00;[=0]0 into the Type field

from http://www.ozgrid.com/Excel/CustomFormats.htm

2
  • You mean 0.00;[=0]0 -- Otherwise, a very nice answer!
    – anon
    Feb 12, 2011 at 3:30
  • Excel number formatting drives me MAD. There is no simple solution to many common problems. Example: maximum X number of decimal places with no trailing zeroes, and no decimal for whole numbers. You HAVE to use conditional formatting. So incredibly stupid.
    – Rick
    Feb 10, 2015 at 18:14
0

Try this:

=IF(A1=0,"0",TEXT(A1,"0.00"))

0

An alternative that includes a separator for thousands, shows negative values in red font and aligns zeros with whole numbers:

#,##0.00;[Red]-#,##0.00;0    

(for the alignment, there are three blanks at the end).

0

From Excel Help:

A number format can have up to four sections of code, separated by semicolons. These code sections define the format for positive numbers, negative numbers, zero values, and text, in that order.

;;;

So All you really need to do is something like 0.00,-0.00,0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.