Search a range for a match within an array; return "Y" if cell value match is found?

vgoodbldg

New Member
Joined
Feb 23, 2021
Messages
3
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have two pages, each with 2 columns of addresses per row.

I am trying to search for duplicate address values across columns on each sheet. I need to return "Y" in a third column on page 2 if one or both columns on page 1 contain a value from page 2's respective row. The value in A4 on page 1 might be in B100 on page 2, and vice versa.

Can I do this without a VBA?

Thank you!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
a countif() may work, or countifs()
But just to be clear
sheet 2 has
Book4
AB
25a
32b
41c
Sheet2


And Sheet 1 has
Book4
AB
24a
35e
41w
Sheet1


so would the highlight cells match
or do they both need to be on the same row
 
Upvote 0
anyway - heres a formula for if either match
Book4
ABC
25aY
32b 
41cY
Sheet2
Cell Formulas
RangeFormula
C2:C4C2=IF(COUNTIF(Sheet1!A2:A4,Sheet2!A2)+COUNTIF(Sheet1!B2:B4,Sheet2!B2)>0,"Y","")


Book4
AB
24a
35e
41w
Sheet1
 
Upvote 0
anyway - heres a formula for if either match
Book4
ABC
25aY
32b 
41cY
Sheet2
Cell Formulas
RangeFormula
C2:C4C2=IF(COUNTIF(Sheet1!A2:A4,Sheet2!A2)+COUNTIF(Sheet1!B2:B4,Sheet2!B2)>0,"Y","")


Book4
AB
24a
35e
41w
Sheet1
Thank you! This works for about 75% of the workbook, but the problem is when columns are referencing the other columns.

A can be in column 1 or 2, and B can be in column 1 or 2. As long as the value of A or B is a match the array, then Y.

I tried adding an additional two countifs, but failed:

=IF(COUNTIF(Sheet1!A2:A4,Sheet2!A2)+COUNTIF(Sheet1!A2:A4,Sheet2!B2)+COUNTIF(Sheet1!B2:B4,Sheet2!B2)+COUNTIF(Sheet1!B2:B4,Sheet2!A2)>0,"Y","")
 
Upvote 0
you can just extend the range
=IF((COUNTIF(Sheet1!A2:B4,Sheet2!A2)+COUNTIF(Sheet1!A2:AB4,Sheet2!B2))>0,"Y","N")
so you are looking for the value in Cell A2 to be anywhere in the columns A OR B - OR - if the value in Cell B2 to be anywhere in the columns A and B

Add $ to fix the range
=IF((COUNTIF(Sheet1!$A$2:$B$4,Sheet2!A2)+COUNTIF(Sheet1!$A$2:$A$B4,Sheet2!B2))>0,"Y","N")
 
Upvote 0
Solution
you can just extend the range
=IF((COUNTIF(Sheet1!A2:B4,Sheet2!A2)+COUNTIF(Sheet1!A2:AB4,Sheet2!B2))>0,"Y","N")
so you are looking for the value in Cell A2 to be anywhere in the columns A OR B - OR - if the value in Cell B2 to be anywhere in the columns A and B

Add $ to fix the range
=IF((COUNTIF(Sheet1!$A$2:$B$4,Sheet2!A2)+COUNTIF(Sheet1!$A$2:$A$B4,Sheet2!B2))>0,"Y","N")
Perfection. Thank you kind stranger.
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,846
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top