View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
salgud salgud is offline
external usenet poster
 
Posts: 219
Default formula doesn't work

On Wed, 12 Nov 2008 16:38:59 -0500, Rick Rothstein wrote:

The RIGHT formula is returning text and I *think* Excel is converting the 80
to text and then doing the comparison. Since letters are always "greater"
than text-numbers (ASCII values are being compared), your comparison is
always returning TRUE. If you convert the return value from the RIGHT
function to a number, then the comparison will work correctly...

=IF(--RIGHT(F27,2)80,RIGHT(F27,2)+1900,RIGHT(F27,2))

If you want the displayed value for your FALSE condition to be a number
(right now it is text), place the double unary (two minus signs) in front of
it as well...

=IF(--RIGHT(F27,2)80,RIGHT(F27,2)+1900,--RIGHT(F27,2))

You don't need to do this for your TRUE condition because Excel
automatically converts text-numbers to real numbers when they are part of a
mathematical operation (like the addition of the 1900 that you are doing).


Thanks a lot. This works great. Never would have thought XL comparing ASCII
instead of numbers, but it makes sense.