I am trying to compare two set of column ranges in Excel.
i am aware of the standard comparison formula :
Eg. =(A1=E1)
What I am looking for is a replacement for the following formula
=AND(A1=E1,B1=F1,C1=G1)
since the number of columns is large I was thinking if it is possible to use a cell range.
Perhaps,
Larger ranges could be handled with the newer textjoin.
If you don't have the newer TextJoin function, here is a quick VBA UDF (user defined function) that you can use to substitute.
A bit slower than @Chronocidal, just to observe that
also works if entered as an array formula using
CtrlShiftEnter
=SUMPRODUCT(PRODUCT(--(A1:D1=E1:H1)))
The
SUMPRODUCT
is to force it to evaluate as an Array FormulaThe
PRODUCT
multiplies all of the valuesThe
--
convertsTRUE
into1
andFALSE
into0
A1:D1=E1:H1
, evalauated as an Array Formula, gives the array{A1=E1,B1=F1,C1=G1,D1=H1}
So, the array is calcuated as a list of
TRUE
andFALSE
. The--
converts this into a list of1
s and0
s, and thePRODUCT
multiplies all the values in the list together. (Multiplication of1
and0
is the same asAND
withTRUE
andFALSE
) - if you use "Evaluate Formula", you can step through and watch it happen{EDIT} As Tom Sharpe pointed out in his answer, I've overcomplicated this slightly - you can use
AND
instead ofPRODUCT
, like so:=SUMPRODUCT(--AND(A1:D1=E1:H1))