• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Formatting numbers

Rachel

New Member
If i've got a column of values where some include pennies and some are just whole pounds, is there a way that i can format the column so that whole pounds show to no decimal places but the lines with pennies still show to two decimals? I know i could do it with an IF statement but i wondered if there was a simpler way?
 
In 2007 or later, you might be able to do that with a conditional format (not sure if they added this, can anyone confirm/deny?). If so, you just need to check if a number has decimals like this:

=MOD(A2,1)<>0


Beyond that, I think that scenario is beyond the basic conditions you can do with a custom number format. Just for note for other users, the formula would be something like:


=IF(MOD(A2,1)=0,TEXT(A2,"$#,##0"),TEXT(A2,"$#,##0.00"))


The problem is that this results in a text output, not a number. Personally, I think it would look cleaner and better aligned to just have all the numbers display 2 decimals.
 
if one doesn't mind the dollar, pounds and penny signs then all you have to do is set the cell format to General. I just did and it works.


I agree with Luke M that showing 2 decimal places on the column makes it more consistent and professional looking.
 
@fred


The problem with General format is that if you have 1 pound and 10 pennies, it will display as "1.1" (1 decimal)
 
Back
Top