I know that when I've run into these scenarios, I've always ended up kicking myself for deleting data. I always advocate TESTING data more thoroughly before I just decide to terminate something. So, even though I think the VBA approach is elegant, I would go for an equation approach first, and give myself some easy flags for a mass-deletion. Equations below, and in picture.
Column C testing if this is the first occurrence of data:
=IFERROR(IF(ROW(A2)<MATCH(A2,B:B,0),"First","Duplc"),"First")
Column D, testing if this is the first occurrence of a data:
=IFERROR(IF(ROW(B2)<MATCH(B2,A:A,0),"First","Duplc"),"First")
Column E, testing for First/First, Duplicate/Duplicate, or new single first occurances of data:
=IF(AND(C2="First",D2="First"),"Keep",IF(AND(C2="Duplc",D2="Duplc"),"Delete","Review"))
Any time I would see a "Review" cell, I'd test to make sure that I'm not deleting a valuable data point. Your data may be more simple than what I'm doing here, but I've regretted the ultra-powerful mass deletion.
If the values in column1 matches any cell in column2, the row should be deleted
yet in your example, the output includesAB CD
even thoughCD
is in column 22 (you said any cell)... same for the the other example output. You should probably re-think your explanation. – ashleedawg