'Check if array contains text from a list and when a value apears more then once display that value

What if I have 4 columns with data, and want the value that is more than once in those 4 columns(A-B-C-D).

apple  pear  melon  grape
melon  apple melon  grape
pear   melon melon  pear

My list in column E is;

``
apple
pear
melon
grape

And what I would like is that in column F the value appears of the fruit that is more than once in a row. 
So F1 should return nothing, F2 should return "melon", and F3 should return "pear, melon"

Is that posible with a formula?


Solution 1:[1]

Try,

In B1, array ("Ctrl"+Shift"+"Enter") formula copied down :

=MID(TEXTJOIN(", ",,FILTERXML("<a>A<b>"&SUBSTITUTE(TRIM(A1)," ","</b><b>")&"</b></a>","a|a/b[not(preceding::* =.)][following::* =.]")),4,999)

Remark : If you have Office 365, the above formula is normal entry.

enter image description here

If source data put in separated cells, then formula become >>

In F1, array ("Ctrl"+Shift"+"Enter") formula copied down :

=MID(TEXTJOIN(", ",,FILTERXML("<a>A<b>"&TEXTJOIN("</b><b>",,A1:D1)&"</b></a>","a|a/b[not(preceding::* =.)][following::* =.]")),4,999)

Remark : If you have Office 365, the above formula is also normal entry.

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1