## Compare two columns in different worksheets

There are multiple columns in two different worksheets, one has more columns than another. I need to compare column F of worksheet 1 and column E of worksheet 2; if the value matches, compare column G of worksheet 1 and column F of worksheet 2; if the value matches, record the value in column N of worksheet1 from column M of worksheet 2. Please see example below.

Worksheet 1:

Column F Column G Column N

Item Code Item Sub-Code Bank Fee

1 0

2 0

4 0

8 0

28 0

Worksheet2:

Column E Column F Column M

Item Code Item Sub-Code Bank Fee

1 0 60

2 0 165

4 0 60

8 0 250

8 2 33

28 0 15

28 1 16.5

Appreciate your help in advance!

Array formula in cell N2, worksheet 1:

### How to enter an array formula

- Copy and paste the formula above in to cell N2
- Press and hold CTRL + SHIFT simultaneously
- Press Enter once
- Release all keys.

The formula is now surrounded by curly brackets, like this {=formula} if you did it right. Check your formula bar and make sure you have the curly brackets.

Then copy cell N2 and paste to cells below.

### Explaining array formula

The steps below is for cell N2 formula.

**Step 1 - Compare cell F2 (sheet1) with column F (sheet2)**

F2=Sheet2!$F$2:$F$8

becomes

1={1;2;4;8;8;28;28}

and returns

{TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}

**Step 2 - Compare cell G2 (sheet1) with column G (sheet2)**

G2=Sheet2!$G$2:$G$8

becomes

0={0;0;0;0;2;0;1}

and returns

{TRUE;TRUE;TRUE;TRUE;FALSE;TRUE;FALSE}

**Step 3 - Multiply arrays**

(F2=Sheet2!$F$2:$F$8)*(Sheet1!G2=Sheet2!$G$2:$G$8)

becomes

({TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}) * ({TRUE;TRUE;TRUE;TRUE;FALSE;TRUE;FALSE})

and returns

{1;0;0;0;0;0;0}

**Step 4 - Use IF function to replace calculated values with sheet2 values from column N, if TRUE (1)**

IF((F2=Sheet2!$F$2:$F$8)*(Sheet1!G2=Sheet2!$G$2:$G$8), Sheet2!$N$2:$N$8, "")

becomes

IF({1;0;0;0;0;0;0}, Sheet2!$N$2:$N$8, "")

becomes

IF({1;0;0;0;0;0;0}, {60;165;60;250;33;15;16.5}, "")

and returns

{60;"";"";"";"";"";""}

**Step 5 - MIN function finds the number in the array, ignores logical and text values**

MIN(IF((F2=Sheet2!$F$2:$F$8)*(Sheet1!G2=Sheet2!$G$2:$G$8),Sheet2!$N$2:$N$8,""))

becomes

MIN({60;"";"";"";"";"";""})

and returns 60.

### Download excel *.xlsx file

### Category: Compare

How to find common values from two lists

Question: How can I compare two columns to find common values? Array formula in C2: =INDEX($A$2:$A$11, SMALL(IF(COUNTIF($B$2:$B$11, $A$2:$A$11), MATCH(ROW($A$2:$A$11),ROW($A$2:$A$11)), ""), […]Comments(13) Filed in category: Compare, Excel

Compare pricelists in excel 2007

This post describes how to compare two price lists in excel 2007. I am going to create three conditional formatting […]Comments(7) Filed in category: Compare, Excel

Compare two lists of data: Filter common row records in excel

This blog post describes how to extract common rows (records) from two lists in excel 2007. Sheet: List 1 Sheet: […]Comments(7) Filed in category: Compare, Excel, Records

Comments(5) Filed in category: Compare, Excel, Unique distinct values

Compare two tables in excel: Remove common rows

Table of Contents Compare two tables: Remove common rows Compare two tables using a condition Let me demonstrate how to extract […]Comments(5) Filed in category: Compare, Records

Filter values that exists in all three lists

Peter Voss asks: This is close to what I need. I have three lists of email addresses. If an email […]Comments(5) Filed in category: Compare, Excel

What values are missing in List 1 that exists i List 2?

Question: How to filter out data from List 1 that is missing in list 2? Answer: This formula is useful […]Comments(4) Filed in category: Compare, Excel, Missing values

Filter common values from three columns in excel

Question: How do I filter values that exists in all three columns? Answer: Formula in A14: =INDEX(List1, MATCH(0, COUNTIF($A$13:A13, List1)+IF(IF(COUNTIF(List2, […]Comments(4) Filed in category: Compare, Excel

Compare and filter values between two lists in excel

Question: Hi, I have seen a lot of examples related to unique list ... mais not found what I need. […]Comments(4) Filed in category: Compare, Excel

Compare values between two columns and filter values existing in only one column

There are text values in column A and column B. The question is how do you compare the values in […]Comments(3) Filed in category: Compare, Excel