# Extracting the common values found in Column "A" & Column "B" into Column "C"

1. ## Extracting the common values found in Column "A" & Column "B" into Column "C"

Hello to All!!!

Hope everyone is fine there. I have great respect for my seniors, teachers and Excel Experts out there. I really respect all of you!!!!

Let's get to the problem.

I have values in Columns "A" & "B".
My problem is very simple. I want to compare the values found in column A and Column B, and extract the common values into the column "C".

Any help would be greatly appreciated.

Workbook named "ExtractingCommonValues" is attached.

2. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

One way:

=IFERROR(INDEX(\$B:\$B,SMALL(IF(ISNA(MATCH(\$B\$2:\$B\$17,\$A\$2:\$A\$17,0)),"",ROW(\$B\$2:\$B\$17)),ROWS(\$2:2))),"")

Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

Don't type the curly brackets yourself - it won't work...

3. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

Try this Array Formula which requires confirmation with Ctrl+Shift+Enter instead of Enter alone.

In D2
``Please Login or Register  to view this content.``
Confirm with Ctrl+Shift+Enter and copy it down.

4. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

Another way, doesn't need array confirmation.
Formula:
`Please Login or Register  to view this content.`
or
Formula:
`Please Login or Register  to view this content.`

5. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

or indeed, another non-array effort:

=IFERROR(INDEX(\$A:\$A,AGGREGATE(15,6,ROW(\$A\$2:\$A\$17)/(ISNUMBER(MATCH(\$A\$2:\$A\$17,\$B\$2:\$B\$17,0))),ROWS(\$1:1))),"")

6. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

Useless fact for the day, with aggregate set to ignore errors, sign does the same as isnumber but less typing involved

7. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

I cannot thank you enough, all of you! Thanks alot!

Apart from array formulae, I tried another rather simple formula. I am copying the formula down.

=IF(COUNTIF(\$B\$2:\$B\$13,\$A\$2:\$A\$13)=1,INDEX(\$A\$2:\$A\$13,ROWS(\$A\$2:A2)),"")

it is producing the same results as other array formulae. is that okay too?

8. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

If it's producing the right results, then it must be OK! Where did you get this formula?

9. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

it is producing the same results as other array formulae. is that okay too?
Only you can answer that question. The real decider would be which one gives the answers how you want them.

The formulae that I suggested would move all of the results to the top (no blanks in the middle). The results would be in numerical order, lowest value first.

The formulae that Glenn and sktneer suggested appear to do the same with the blanks, but the results would be in list order instead of numeric.

Your formula doesn't separate the results from the blanks, it just mirrors them in the same row as the original entry.
If that is a good enough result then
Formula:
`Please Login or Register  to view this content.`
will do the same.

10. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

yes, my formula is producing the right results too. You are right, My formula mirrors them in the same row.

I have another question regarding the 2nd formula presented by Respectable Jason.b75 copied below:

=IFERROR(AGGREGATE(15,6,\$A\$2:\$A\$17/COUNTIF(\$B\$2:\$B\$17,\$A\$2:\$A\$17),ROWS(D\$2:D2)),"")

in above formula, in countif function, if i interchange the column "B" for criteria argument of countif function and vice versa, like this, COUNTIF(\$A\$2:\$A\$17,\$B\$2:\$B\$17).

why is it producing the wrong results, here arrays are compared, not one cell. I am just confused. Please help me understand this concept.

11. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

You will see that the reference to column A appears in 2 places.

=IFERROR(AGGREGATE(15,6,\$A\$2:\$A\$17/COUNTIF(\$B\$2:\$B\$17,\$A\$2:\$A\$17),ROWS(D\$2:D2)),"")

If you swicth the order of countif then you would need to change the first one to B as well, otherwise the order will be incorrect.

One thing to note, if any number appears more than once in A or B then there is a high risk of incorrect results with this method. I think that all of the other suggestions should be safe from this problem.

12. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

Understood! Loud and Clear, Thanks alot to all who replied to the thread. I am looking forward to contribute someday soon like all of you.
I am marking this thread solved.

Take Care

Thanks & Regards

13. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

With dynamic array functions in Office 365, this is as simple as this...

``Please Login or Register  to view this content.``
The above formula will return unique sorted common values from the two ranges.

Dynamic Array Functions are just awesome.

14. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

Thanks Dear Sktneer...

15. ## Re: Extracting the common values found in Column "A" & Column "B" into Column "C"

There are currently 1 users browsing this thread. (0 members and 1 guests)