Searching and adding a value.

R

rmg

Hi,

I have 1 workbook with 2 worksheets.

Worksheet 1 has:
Column a
nm123
mf837
mn187
lk193

Worksheet 2 has:
Column a Column b
kd298 x
er549 x
jk981 y
nm123 x
mf837 x
lp182 y
nj765 y
mn187 t

As you can see, three of the values in worksheet 1 column a are also in
worksheet 2 colum a.

If that is the case I want to populate worksheet 1 column b with the
relevant value from worksheet 2 column b

e.g. in worksheet 1 I would end up with:

Column a Colum b
nm123 x
mf837 x
mn187 t
lk193 (Blank because its not in worksheet 2 column a

I think I can do it with a VLOOKUP but Im struggling with what to put
in.

Please can anyone help?

Thanks.
 
B

Bearacade

Put this in Sheet1, B1

=IF(COUNTIF(Sheet2!$A:$A,A1)>0, VLOOKUP(A1,Sheet2!$A:$B,2,FALSE), "")

You have to put the if statement in there or else you are going to get
#N/As
 
R

rmg

Bearacade said:
Put this in Sheet1, B1

=IF(COUNTIF(Sheet2!$A:$A,A1)>0, VLOOKUP(A1,Sheet2!$A:$B,2,FALSE), "")

You have to put the if statement in there or else you are going to get
#N/As

Thank you very much Bearacade.
 
Top