View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David Biddulph[_2_] David Biddulph[_2_] is offline
external usenet poster
 
Posts: 8,651
Default Help with if statement

It looks like it's returning the correct result to me.
The string "10 years, 11months" satisfies the
AND(E203"0years,6months",E203<="2years,0months") condition, because the
first digit 1 is greater than 0 and is less than 2.
Perhaps you've forgotten that you are comparing text strings, not comparing
numbers?
--
David Biddulph


"ck" wrote in message
...
I have used the following statement, but it is returning an incorrect
result
for some cells. In an cell containing an age of 10 years, 11months..the
formula is returning "6m-2y" when it should say older than 2. It also
does
this for the age 25 years 6 months and 18 years 10 months. Please help.

=IF(AND(E203="0years,0months",E203<="0years,3mont hs"),"0-3",IF(AND(E203"0years,3months",E203<="0years,6mon ths"),"3-6",IF(AND(E203"0years,6months",E203<="2years,0mon ths"),"6m
- 2y",IF(AND(E203"2years,0months",E203<="99years,0m onths"),"Older than
2",""))))