开发者

Conditional Decimal Format

开发者 https://www.devze.com 2023-02-10 14:55 出处:网络
I want to format a number with开发者_如何学编程 two decimals unless it\'s 0.Can I do this? 123.93

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


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


Try this:

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


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).


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

0

精彩评论

暂无评论...
验证码 换一张
取 消