Need help with nested IF comparison....

D

Dan B

Need some help with correct syntax...
I have 3 columns of data to compare. In the 2nd and 3rd columns, I want to
look for matching numbers. Where a match is found, I want to check for a 1
in the 1st column. If all that matches, I want to copy the matching number
in the 3rd column to a blank 4th column.

Basically, If B2 = any number in C2 thru C50, and A2=1 then copy B2 to D2.

I hope that makes sense.

Thanks
 
T

Tom Ogilvy

if Range("A2").Value = 1 and _
Application.Countif(Range("C2:C50"), _
Range("B2").Value) > 0 then
Range("D2").Value = Range("B2").Value
End If


for for a formula

=if(And(A2=1,countif(C2:C50,B2)>0),B2,"")
 
J

JulieD

Hi Dan

i think the following formula for D2 gives you what you're after
=IF(AND(COUNTIF($C$2:$C$50,B2),A2=1),B2,"")

Cheers
JulieD
 
Top