keepcalculator

06 Numbers and Powers

Multiple Columns Are Equal? Check in Excel

Card No. 06·62909 · Updated · Standard formula, shown below

The calculator on this card is switched off while it is checked. The formula is below, and the worked example shows how to do the sum by hand.

This guide shows you how to check whether two or more columns in Excel contain exactly the same values, and it explains the best formulas and tools for the job. You enter the cell ranges you want to compare, and you get a clear TRUE/FALSE or a count of differences as the result.

Formula

The core idea is to compare the two ranges cell by cell and count how many pairs do not match. If that count is zero, the columns are equal.

In words: Equal = (Count of non-matching cells) = 0

Using SUMPRODUCT, the formula is:

=SUMPRODUCT(--(A1:A10<>B1:B10))

Where:

  • A1:A10 – first column range
  • B1:B10 – second column range
  • <> – “not equal to” operator
  • — – converts TRUE/FALSE to 1/0
  • SUMPRODUCT – adds up the 1s

The result is the number of cells that differ. If it returns 0, the columns are identical.

Worked Example

Using the default values from the calculator above, compare A1:A10 with B1:B10.

  1. Assume A1:A10 contains: 5, 8, 12, 20, 3, 7, 9, 15, 6, 11
  2. Assume B1:B10 contains: 5, 8, 12, 21, 3, 7, 9, 15, 6, 11
  3. Compare each pair: only row 4 differs (20 vs 21).
  4. SUMPRODUCT counts 1 difference.
  5. The formula returns 1, so the columns are not equal.

If all ten pairs matched, the result would be 0, meaning the columns are equal.

Why Compare Columns?

Comparing columns is a daily task for anyone cleaning data, reconciling lists, or verifying entries. You might have two versions of a price list, a list of IDs from two systems, or survey responses entered twice. Manual checking is slow and error-prone, especially with hundreds of rows. A formula gives an instant, reliable answer.

This simple comparison checks positional equality – it compares row 1 to row 1, row 2 to row 2, and so on. It does not check whether the same values exist in both columns in a different order. For that, you would need a different approach, like sorting both columns first or using a lookup.

How to Choose the Right Method

Depending on what you actually need, one of these methods will fit better:

  • Exact same order, same rows: use the SUMPRODUCT formula above.
  • Same values, any order: sort both columns ascending, then use the same formula.
  • Find which rows differ: add a helper column with =A1=B1 and filter for FALSE.
  • Compare two columns for duplicates: use conditional formatting or COUNTIF.
  • Compare more than two columns: extend the formula with additional comparisons, e.g. =SUMPRODUCT(--(A1:A10<>B1:B10))+SUMPRODUCT(--(B1:B10<>C1:C10))

Common Problems and Mistakes

The most frequent issue is assuming two columns are equal when they only look alike. Hidden spaces, different number formats, or text vs. numbers can cause mismatches.

  • Trailing spaces: “Apple ” and “Apple” look the same but are not equal. Use TRIM to remove spaces.
  • Number stored as text: a cell containing 5 as text and a cell containing 5 as a number will compare as different. Convert text to numbers with VALUE or by multiplying by 1.
  • Case sensitivity: the default comparison is case-insensitive. If you need case-sensitive, use EXACT.
  • Blank cells: an empty cell and a cell with a space are different. Be aware of this when comparing imported data.

Comparing More Than Two Columns

If you have three or more columns and want to know if they are all identical, you can compare each column to the first one. The formula becomes:

=SUMPRODUCT(--(A1:A10<>B1:B10))+SUMPRODUCT(--(A1:A10<>C1:C10))

If the result is 0, all columns match the first column, so they are all equal. This works for any number of columns – just add another SUMPRODUCT for each additional column.

Alternatives to Formulas

If you prefer not to write formulas, Excel has built-in tools:

  • Conditional Formatting: select both columns, go to Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values. This highlights matches, but it does not directly tell you if the columns are equal.
  • Go To Special: select both columns, press F5, click Special, choose Row Differences. This selects cells that differ from the active cell in each row.
  • Power Query: load both columns as separate queries, merge them on the values, and see which rows do not match. This is powerful for large datasets.

Frequently Asked Questions

Why does my formula return 0 but the columns look different?

This usually happens when the difference is invisible – a trailing space, a different number format, or a formula that returns the same displayed value but a different underlying value. Use TRIM to remove spaces and check the actual cell contents with the formula bar.

How do I compare two columns for missing values?

Use COUNTIF to check if each value in column A appears in column B. For example, =IF(COUNTIF(B:B,A1)=0,"Missing","") in a helper column will flag values in A that are not in B.

Can I compare columns ignoring case?

Yes, the default comparison with <> is case-insensitive. If you need case-sensitive comparison, use =SUMPRODUCT(--(EXACT(A1:A10,B1:B10)=FALSE)).

What if my columns have different lengths?

The SUMPRODUCT formula requires ranges of the same size. If one column is longer, either extend the shorter range with blanks or compare only the overlapping rows. For a true comparison of different-length lists, you need a different approach like COUNTIF.

Does this work in Google Sheets?

Yes, the same SUMPRODUCT formula works in Google Sheets. The syntax is identical, so you can copy the formula directly.

How do I compare two columns and highlight differences?

Select both columns, go to Home > Conditional Formatting > New Rule > Use a formula. Enter =$A1<>$B1 and set a fill color. This highlights every row where the two cells differ.

Related

Formula used
in a | First column range | - | A1:A10 | 0
in b | Second column range | - | B1:B10 | 0
out equal | Columns equal? | - | IF(SUMPRODUCT(--(ab))=0,"TRUE","FALSE") | 0
out diff | Differences found | - | SUMPRODUCT(--(ab)) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →