Compare Two Excel Lists Regardless of Order
Question details
Compare two lists of names as equal when they contain the same values, even if the values appear in a different 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.
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 ?.
Compare Two Lists in Excel Ranges
Use COUNTIF and SUMPRODUCT to compare names in two ranges, including repeated names.
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.
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").
Press Enter. The cell returns EQUAL when each name occurs the same number of times in both ranges; otherwise, it returns UNEQUAL.

Compare Comma-Separated Lists in Two Excel Cells
Use this formula when each list is stored in one cell and your Excel version supports TEXTSPLIT, LET, and SORT.
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. Open the workbook: In WPS Office, open your Excel workbook in Spreadsheets.
- 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. 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. Check and save: Press Enter to see EQUAL or UNEQUAL, then use File > Save to save the workbook.

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.




