View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove[_2_] Harlan Grove[_2_] is offline
external usenet poster
 
Posts: 1,231
Default Complex IF THEN statement

Greg S <Greg wrote...
HI...I'm trying to figure out how to do a long IF THEN statement. *I have
three columns. *Column 1 is validated data with 20 possibilities. *Column two
is validated data with 15 possibilities. *I want the third column to
automatically fill in based on the values in columns 1 & 2. *

....

How would the 3rd column automatically fill in based on the 1st and
2nd columns? By looking up the 1st and 2nd column values in a 3-column
table elsewhere? By generating different labels in the 3rd column for
each distinct combination of entries in the 1st and 2nd columns?
Something else?

How were the Restaurant # entries in the 3rd column of your sample
table determined? Were they just more entries along with the 1st and
2nd columns? If so, it'd seem you want to perform table lookups. If
your source table were named TBL and you the 1st and 2nd column values
you wanted to look up were in cells C5 and D5, you could use an array
formula like

=INDEX(SRC,MATCH(1,(INDEX(SRC,0,1)=C5)*(INDEX(SRC, 0,2)=D5),0),3)

On the other hand, if you wanted to generate unique labels consisiting
of the word Restaurant followed by a space followed by a different
number for each combination of entries in the 1st and 2nd columns, and
if the top-left cell of the table were A1, you could use formulas like

C1:
Restaurant 1

C2:
=IF(COUNT(MATCH(1,COUNTIF(A2,A$1:A1)*COUNTIF(B2,B$ 1:B1),0)),
INDEX(C$1:C1,MATCH(1,COUNTIF(A2,A$1:A1)*COUNTIF(B2 ,B$1:B1),0)),
"Restaurant "&(MAX(--SUBSTITUTE(C$1:C1,"Restaurant ",""))+1))

Fill C2 down in column C as far as needed.