assuming that your data ranges are A1:A10 and E1:E10, try in F1 as an ARRAY-entered formula:
=COUNT(1/FREQUENCY(IF({1,0},IF(COUNTIF(A1:A10,A1:A10),A1:A10),IF(COUNTIF(E1:E10,E1:E10),E1:E10)),IF({1,0},IF(COUNTIF(A1:A10,A1:A10),A1:A10),IF(COUNTIF(E1:E10,E1:E10),E1:E10))))
this solution will only work if you have numerical entries in your ranges.
the {1,0} trick is courtesy daddylonglegs.
UPDATE
another, simpler, more extensible solution (again, ARRAY-entered):
=COUNT(1/FREQUENCY(CHOOSE({1,2},-A1:A10,-E1:E10),CHOOSE({1,2},-A1:A10,-E1:E10)))-1
in case you have other columns, such as C1:C10, the above formula can be extended thus:
=COUNT(1/FREQUENCY(CHOOSE({1,2,3},-A1:A10,-C1:C10,-E1:E10),CHOOSE({1,2,3},-A1:A10,-C1:C10,-E1:E10)))-1
in case your data were along rows (instead of columns), the formula would be (observe the use of ";" instead of ","):
=COUNT(1/FREQUENCY(CHOOSE({1;2;3},-A1:J1,-A2:J2,-A3:J3),CHOOSE({1;2;3},-A1:J1,-A2:J2,-A3:J3)))-1
Bookmarks