# Help with code statement

N

#### newbie

Could someone help me understand what this code snippet is doing? I am
new at this and just learning. I am trying to comment this code to
understand what is happening but its not completely correct.

=IF(COUNTIF(Promotion!\$A\$2:\$A\$41,A7)>1,LOOKUP(2,1/(Promotion!\$A\$2:\$A
\$41=A7),Promotion!\$C\$2:\$C\$41),"")

=IF
(COUNTIF
(Promotion!\$A\$2:\$A\$41,A7)>1,

range is defined and is compared to cell A7 which is person id, if
person id is found more than once, then

LOOKUP(2,1/(Promotion!\$A\$2:\$A\$41=A7),

The syntax for the Lookup function is:

Lookup( value, lookup_range, result_range )
2 , 1/A\$2:\$A\$41=A7

So it looks like the look up looks for 2 and then why 1/lookup range?
what does this do for you?

Promotion!\$C\$2:\$C\$41),

"")
Does "" mean if the condition isnt met u get "" or no data printed?

D

#### Dave Peterson

If there are at least 2 cells in A2:A41 of the promotion worksheet that are
equal to the value in A7, then the next portion returns the entry in column C
(C2:C41) that has the last match in column A.

(promotion!a2:a41=a7)
will return a 40 element array of true and false values.

1/(true or false)
will either be 1 or a divided by 0 error (true=1, false=0 when used in
arithmetic)

lookup(2,(array or 1's or errors))
will find that last 1--the last matching entry for A7.

And the lookup() will return that value in column C for the matching row.