View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default more than 4 if functions?

On Oct 1, 6:48 am, Joy wrote:
I have 2 colums of numbers and I need to find out this criteria.
Do I use the If function?


You could. Alternatively....

A129 and B117 = 1
A129 and B1<17 = 2
A1<29 and B117 = 3
A1<29 and B1<17 = 4
A1=29 and B1=17 = 5

[.... And you later wrote the following errata ....]
I should have said that if A1=29 or B1=17 then it needs to say 5.


The following seems to fit your corrected criteria:

=1 + AND(A1<29,B1<17) + 2*AND(A1<29,B1<17) + 4*OR(A1=29,B1=17)

This produces the following results:

a29,b17: 1
a29,b<17: 2
a<29,b17: 3
a<29,b<17: 4
a=29,b=17: 5
a=29,b17: 5
a29,b=17: 5
a=29,b<17: 5
a<29,b=17: 5

Essentially, think of the result as a binary number where bit1 is 0 or
1 based on B<17 (and A<29), bit2 is 0 or 1 based on A29 (and B<17),
and bit3 is 0 or 1 based on A=29 or B=17. That would result in 0-4
since binary numbers represent the sum of powers of 2, viz. 1*bit1 +
2*bit2 + 4*bit3. Add 1 for the results 1-5.

(Note: Normally bits are numbers 0,1,2,... to match their respective
power of 2.)