# Loop through 2 columns and and return TRUE or FALSE if adjscent cells are matching.

#### strongman86

##### Board Regular

Need formula in cell E1 that loops through Columns A & C and if cell value is identical i.e. AB1234X vs AB1234X then it need to compare corresponding adjscent cell values in column B & D to see if they are matching. If they are matching then it needs to return TRUE if not matching then FALSE.

 A B C D E 1 AB1234X 2.40 AD2456Y 0.24 FALSE 2 AU1336X 1.20 AB1234X 2.40 TRUE 3 AD2456Y 0.20 ZN3590Q 1.54 TRUE 4 TR3456U 5.50 AU1336X 1.20 TRUE 5 ZN3590Q 1.54 TR3456U 5.52 FALSE

<tbody>
</tbody>

Regards,
Strongman86

#### Fluff

##### MrExcel MVP, Moderator
=ISNUMBER(MATCH(C2&"|"&D2,INDEX(\$A\$2:\$A\$6&"|"&\$B\$2:\$B\$6,0,0),0))

#### Jon von der Heyden

##### MrExcel MVP, Moderator
Try:

=IFERROR(VLOOKUP(C1,A:B,2,0)=D1,FALSE)

#### strongman86

##### Board Regular
Hi Fluff, Works ok, but I've noticed sometimes some cells in column C has space after text and then formula doesn't work. Can you amend formula so it looks only for first 7 characters? Thanks.

#### Fluff

##### MrExcel MVP, Moderator
=ISNUMBER(MATCH(LEFT(C2,7)&"|"&D2,INDEX(LEFT(\$A\$2:\$A\$6,7)&"|"&\$B\$2:\$B\$6,0,0),0))

#### strongman86

##### Board Regular
Perfect. Thanks Fluff.

#### Rick Rothstein

##### MrExcel MVP
Hi Fluff, Works ok, but I've noticed sometimes some cells in column C has space after text and then formula doesn't work. Can you amend formula so it looks only for first 7 characters? Thanks.
If the spaces could only be in Column C (not Column A) then this formula should work for you...

=COUNTIFS(A\$1:A\$5,TRIM(C1),B\$1:B\$5,D1)>0

Adjust the 5 in the A\$5 and B\$5 to be the last row number for your data.

Last edited: