New Contributor

# Compare comma separated cell contents, show double occurrences

Hello everybody,

I am looking for a solution to the following problem. There are two cells (B26 & D26) with names separated by commas. The number of names is variable (should probably not exceed 40). It must not happen that a name appears in both cells. I would like to have a control function in column F using an Excel formula that warns if a name occurs in cells B and D.

I would be grateful for any help!

---German---

Hallo zusammen,

ich suche nach einer Lösung für folgendes Problem. Es gibt zwei Zellen (B26 & D26) in denen Namen stehen die durch Kommatar getrennt sind. Die Anzahl der Namen ist variabel (sollte 40 wahrscheinlich nicht überschreiten). Es darf nicht vorkommen, das ein Name in beiden Zellen vorkommt. Ich hätte gerne in Spalte F eine Kontrollfunktion per Excel-Formel, die warnt wenn ein Name in Zelle B und D vorkommt.

Danke!

 Zeile B C D E F 26 NameA, NameB NameC, NameD, NameA, NameE =wenn(a Name in B26  = a  Name in D26; "Error!"; "")

PS: Unfortunately, my boss wants it to be displayed like this ... Unfortunately, the table cannot be modified.

2 Replies

# Re: Compare comma separated cell contents, show double occurrences

@sepp89117 I may be wrong but suspect this is not so easy with just a formula. However, when I take your example literally (i.e. compare two cells with comma separated strings and display "Error" if duplicates are noticed), perhaps the attached workbook contains an acceptable solution for you.

It uses PowerQuery (PQ) and requires two named ranges, each pointing at one of the two cells. In my example I named them "cellB26" and cellD26". The query creates separate tables from each cell and checks for matching records, through merging (Inner join) these two tables . If there are matching records, then "Error" will be returned in cell F26. If, on the other hand the merged table is empty (i.e. no matching records found) then F26 remains empty.

Change the content in cells B26 and/or D26 and press "Refresh All" on the Data ribbon and see if it does what you expect.

# Re: Compare comma separated cell contents, show double occurrences

Oops, I believe I answered on that, but my reply for some strange reason disappeared. Anyway, just in case another variant of PQ solution.