This should do it. I made it scalable for if you want to add more columns:
=ROWS(QUERY(ArrayFormula(TO_TEXT(ARRAY_CONSTRAIN($A:$D, ROW()-1, COUNTA(1:1)))), "select "&JOIN(",", ArrayFormula("Col"&({2,3})))&" where "&JOIN(" and ", ArrayFormula("Col"&({2,3})&"='"&ArrayFormula(HLOOKUP(ArrayFormula(VLOOKUP($A$1,$1:$1,({2,3}),0)),$A:$D,ROW(),0))&"'"))))
Readable:
=ROWS(
QUERY(
ArrayFormula(
TO_TEXT(ARRAY_CONSTRAIN(
$A:$D,
ROW()-1,
COUNTA(1:1)
))
),
"select "&
JOIN(
",",
ArrayFormula("Col"&({2,3}))
)&
" where "&
JOIN(
" and ",
ArrayFormula(
"Col"&
({2,3})&"='"&
ArrayFormula(
HLOOKUP(
ArrayFormula(
VLOOKUP(
$A$1,
$1:$1,
({2,3}),
0
)
),
$A:$D,
ROW(),
0
)
)&
"'"
)
)
)
)
Highlight cell if the number of rows with matching cells in previous rows is >0. To add more columns, you'll have to add to every instance of the {2,3}
's. For example, if you want to include D, add a 4 to the arrays.
If you expect to change which columns you want a lot, you can create a separate column elsewhere with the column indexes that you want, then use FILTER in place of the array to save typing.
This highlights any duplicate cell after the original as well.