# Compare Two Columns (from two different worksheets) and show result of another column - excel

I have this scenario:

• Worksheet 1 with Column A only
• Worksheet 2 with Column A and B

I have to compare Column A (Worksheet 1) and Column A (Worksheet 2).

If a value in Column A (Worksheet 1) is existing in Column A (Worksheet 2), it must show the value in Column B (Worksheet 2).

Please help. I have been trying to do this. I can only compare the Column A of both worksheets but I cannot show the Column B.

-

## migrated from stackoverflow.comAug 15 '11 at 19:02

This question came from our site for professional and enthusiast programmers.

What "value" are you looking to place in column B of Sheet2? If you are looking for duplicates, you just want to list the name in column B if it's found in Sheet1? – Issun Aug 15 '11 at 10:29

This sounds like you just need a simple VLOOKUP formula.

``````=VLOOKUP(Sheet1!A2,Sheet2!A1:B20,2,FALSE)
``````

where A2 is the value on Sheet 1 you want to look up, and A1:B20 is the entire table on Sheet2.

-
``````=IF((F2=""),G2,F2)
``````

This means: if cell `F2` is blank, return `G2`, else return the value of `F2`.

-

Use a simple IF formula instead.

In cell B1 enter:

``````=IF(sheet1!\$A1=sheet2!\$A1,\$A1)
``````

and copy down as far as you need to go.

-