• 464K Members
• 12K Online
• 560K Conversations

New Contributor

# Extract shared values between two columns

Hi everyone,

I am trying to extract shared values between two columns. I found a post on another website that has a formula to use, but I am struggling to apply it to my dataset. Below is the formula.

=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)), ""), ROWS(\$A\$1:A1)))

This only works between cells 2-11. I have tried changing the values in the formula to fit my target (column A has 119 values and column B has 193), but for some reason, all I get in return is #VALUE!

I'm not sure what I'm doing wrong, but ideally, I'd like to compare all 119 values in column A with the 193 values in column B and return the shared values in column C, or wherever I enter the formula. I am also figuring out how to apply this with various column lengths since I have a lot of columns to compare, and they all have different lengths.

6 Replies

# Re: Extract shared values between two columns

Formula assumes your data starts from the second row. You may expand your range with some gap, wrap formula with IFERROR and enter it in C2 as an array formula (Ctrl+Shift+Enter), like

`=IFERROR(INDEX(\$A\$2:\$A\$1100, SMALL(IF(COUNTIF(\$B\$2:\$B\$1100, \$A\$2:\$A\$1100), MATCH(ROW(\$A\$2:\$A\$1100),ROW(\$A\$2:\$A\$1100)), ""), ROWS(\$A\$1:A1))),"")`

and drag it down till empty cells appear.

Alternative non-array formula could be with AGGREGATE and with using of dynamic ranges, but that's not critical.

# Re: Extract shared values between two columns

Attached is the document I'm working on. Thanks for your help!

# Re: Extract shared values between two columns

In A2 and B2 there are errors returned. If remove, formula in C2 works.

# Re: Extract shared values between two columns

Amazing! Thank you so much for your help!! @Sergei Baklan

# Re: Extract shared values between two columns

@MGreenfield , you are welcome

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies