Function Problems

Compare Two Excel Lists Regardless of Order

Camila MilosovichCamila Milosovich Nov 25, 2026 869 views

Question details

Compare two lists of names as equal when they contain the same values, even if the values appear in a different order.

Compare Two Excel Lists Regardless of Order
Product
Microsoft Excel
Device & OS
not provided
Scenario
The lists may be stored in separate cell ranges or as comma-separated values in individual cells.
Observed behavior
Lists such as Mary, Sue, Jane and Sue, Jane, Mary should return EQUAL despite their different order.
Before you start

Check whether each list occupies a cell range or a single comma-separated cell, and adjust the cell references in the formula. For the range formula, use nonblank text values without COUNTIF wildcard characters such as * or ?.

Solution 1Recommended

Compare Two Lists in Excel Ranges

Use COUNTIF and SUMPRODUCT to compare names in two ranges, including repeated names.

1
Place the lists in ranges

Enter the first list in A2:A4 and the second list in B2:B4. Change these references in the formula if your lists use different ranges.

2
Enter the comparison formula

Select an empty cell and enter =IF(AND(SUMPRODUCT(--(COUNTIF(A2:A4,A2:A4)<>COUNTIF(B2:B4,A2:A4)))=0,SUMPRODUCT(--(COUNTIF(B2:B4,B2:B4)<>COUNTIF(A2:A4,B2:B4)))=0),"EQUAL","UNEQUAL").

3
Check the result

Press Enter. The cell returns EQUAL when each name occurs the same number of times in both ranges; otherwise, it returns UNEQUAL.

Compare Two Lists in Excel Ranges
Text comparison limits: COUNTIF is not case-sensitive and treats * and ? as wildcards. Use this formula for nonblank names without those characters.
Compare lists in WPS Spreadsheets

Compare Excel Lists with WPS Spreadsheets

Open your workbook in WPS Spreadsheets and use COUNTIF and SUMPRODUCT to compare two ranges without sorting them.

  1. 1. Open the workbook: In WPS Office, open your Excel workbook in Spreadsheets.
  2. 2. Arrange the lists: Place nonblank names in A2:A4 and B2:B4, or adjust the formula references to match your ranges. Avoid names containing * or ?.
  3. 3. Enter the formula: Select an empty cell and enter =IF(AND(SUMPRODUCT(--(COUNTIF(A2:A4,A2:A4)<>COUNTIF(B2:B4,A2:A4)))=0,SUMPRODUCT(--(COUNTIF(B2:B4,B2:B4)<>COUNTIF(A2:A4,B2:B4)))=0),"EQUAL","UNEQUAL").
  4. 4. Check and save: Press Enter to see EQUAL or UNEQUAL, then use File > Save to save the workbook.
Compare names regardless of their orderCheck whether duplicate names occur the same number of timesOpen and save Microsoft Excel XLSX filesUse familiar spreadsheet formulas and cell references
microsoft office alternative - wps office

Frequently Asked Questions

Will the range formula detect duplicate names?

Yes. It compares how many times each name occurs in both ranges, so two instances of Mary will not match one instance.

Does the comparison distinguish uppercase and lowercase letters?

No. Both formulas compare text without distinguishing case, so Mary and MARY are treated as the same name.

Why does the comma-separated formula return a function error?

Check whether your Excel version supports TEXTSPLIT, LET, and SORT. If TEXTSPLIT is unavailable, split the values into cell ranges using Data > Text to Columns, then use the range comparison formula.

Do spaces around comma-separated names affect the result?

The single-cell formula uses TRIM to remove ordinary leading and trailing spaces from each item. For names in ranges, remove unwanted spaces from the cells before comparing them.