View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
[email protected] reitanospa1@yahoo.com is offline
external usenet poster
 
Posts: 38
Default conditionally format anumber format

On Jan 15, 11:32 am, Montana
wrote:
Yes, in the same cell. If the value is 99, I want it to show 99¢. If it is a
dollar, it should read $1.00, not 100¢


It's not as elegant as building a custom format, but you could hide
the data and use a formula to display the data in the way you want it.
Here's an ugly IF function nest that would do it assuming your number
is in D10 and the cent symbol is in G5:

=IF(D10<1,(D10*100)&$G$5,IF(MOD(D10*100,100)=0,"$" &D10&".
00",IF(MOD(D10*100,10)=0,"$"&D10&"0","$"&D10)))

The two mod bits are to deal with even dollar amounts (the first one)
and even tens where Excel likes to trunc the zeros off (note that
formatting the original numbers with 2 decimals of display wouldn't
solve this particular issue).
You could also use CHAR(162) for the cent sign instead.