To compare text in Excel, enter =A2=B2 in C2 and press Enter; TRUE means the text matches, ignoring capitalization. Use =EXACT(A2,B2) when uppercase and lowercase letters must match too.
Choose a comparison based on whether you need matching rows, matches anywhere in another list, or matching parts of a cell. The formula steps below apply to Excel for Microsoft 365 and Excel 2024 on Windows and Mac. The basic equality formula also works in Excel for the web and current iPad, iPhone and Android apps; the highlighting steps identify their platform separately.
The short version
- Same row: Use
=A2=B2to compare two cells without checking capitalization. - Exact text: Use
=EXACT(A2,B2)when capitalization and spaces must match. - Different list order: Use COUNTIF to compare lists in different orders.
- Visible differences: Apply a conditional formatting formula to highlight mismatched rows.
| Your task | Method | What it checks |
|---|---|---|
| Compare corresponding cells | Equality or inequality operator | Matches or differences, ignoring capitalization |
| Compare capitalization too | EXACT | Identical text, including capitalization and spaces |
| Show readable results | IF with a comparison | Returns Match or Different |
| Compare unordered lists | COUNTIF | Counts of cells meeting a criterion, ignoring capitalization |
| Count matches with matching capitalization | SUMPRODUCT with EXACT | Case-sensitive occurrences in another list |
| Find text within a cell | SEARCH | Containment, ignoring capitalization |
| Find text with matching capitalization | FIND | Case-sensitive containment |
| Compare the beginning of text | LEFT with a comparison | A specified number of starting characters |
| Compare the end of text | RIGHT with a comparison | A specified number of ending characters |
| Ignore extra ordinary spaces | TRIM with a comparison | Text after ordinary spacing is normalized |
| Highlight mismatched rows | Conditional formatting formula | Differences between corresponding cells |
| Highlight repeated text | Duplicate Values | Repetition anywhere in the selected range |
| Extract matching or differing rows | FILTER | Rows meeting your comparison condition |
Set up a comparison between two columns
For a row-by-row comparison, use columns A and B for your two sets of text and column C for the results. Select C2, enter the following formula, and press Enter.
=A2=B2TRUE means the text matches without regard to capitalization, while FALSE means it differs. Copy the formula down column C to compare the corresponding cells on each row.
You can reverse the test when you want TRUE to flag a difference. Enter this formula instead, then copy it down.
=A2<>B2Both formulas compare cells by their position, so use them when each row contains the two entries you intend to compare. If the lists have been reordered, use COUNTIF to check each entry against the other list, or match records by a stable key with a lookup.
Your cell references can also point to different worksheets. To compare A2 on Sheet1 with A2 on Sheet2, enter this formula in your result cell.
=Sheet1!A2=Sheet2!A2Make capitalization part of the comparison
Use EXACT to check whether two text values match, including capitalization and spaces. Select C2, enter the following formula, and press Enter.
=EXACT(A2,B2)Copy the formula down to compare the remaining rows. For example, Apple and apple produce FALSE because their capitalization differs.
Cell formatting does not affect your EXACT result. If two entries look alike but return FALSE, inspect their capitalization and spacing before changing the comparison.
Show Match or Different instead of TRUE or FALSE
Use IF to replace logical results with labels that are easier to scan. For a comparison that ignores capitalization, enter this formula in C2, press Enter, and copy it down.
=IF(A2=B2,"Match","Different")You can also use the IF function in Excel to label the result of an EXACT comparison. Enter the following version, press Enter, and copy it down when a change in capitalization should count as Different.
=IF(EXACT(A2,B2),"Match","Different")The labels change how Excel presents your answer, while the comparison inside IF determines what counts as a match. Choose the equality version for capitalization differences you want to ignore, or the EXACT version when those differences matter.
Find matching text anywhere in another list
Use COUNTIF to count cells in a second list that meet A2 as a criterion. To look for A2 within B2 through B100, enter this formula in C2 and press Enter.
=COUNTIF($B$2:$B$100,A2)>0Copy the formula down to check the remaining entries in column A. TRUE means one or more cells meet that criterion, and FALSE means none do. Adjust B100 to match the end of your comparison range.
Remove >0 when you want the number of COUNTIF matches, or replace it with =0 to make TRUE indicate that no cell meets the criterion. Reverse the lists and repeat the comparison to check column B against column A.
COUNTIF ignores capitalization and interprets ? and * as wildcard characters in its criteria. If you want to find an actual question mark or asterisk, type a tilde (~) in front of the character. COUNTIF also returns incorrect results when it matches strings longer than 255 characters. When you need a case-sensitive count, use SUMPRODUCT with EXACT instead.
=SUMPRODUCT(--EXACT(A2,$B$2:$B$100))This formula gives you the number of exact, case-sensitive occurrences of A2 in the second list. Append >0 if you want a TRUE or FALSE membership result instead of a count.
Compare part of a cell’s text
Use SEARCH to check whether one cell contains the text from another cell, ignoring capitalization. To test whether A2 contains the text in B2, enter this formula and press Enter.
=ISNUMBER(SEARCH(B2,A2))TRUE means B2’s text occurs within A2, so it does not establish that the complete cells are equal. You can use the ? and * wildcards with SEARCH. Place ~ before a wildcard character when you want to search for that character literally.
FIND performs a case-sensitive containment check and does not support wildcard matching. Use this version when the capitalization of the text you are looking for must match.
=ISNUMBER(FIND(B2,A2))For a comparison limited to the beginning of each cell, use LEFT. The following formula compares the first three characters without checking capitalization; replace 3 with the number of characters you need.
=LEFT(A2,3)=LEFT(B2,3)Use RIGHT to compare characters at the end of each cell. To compare the final three characters and require matching capitalization, wrap the two RIGHT results in EXACT.
=EXACT(RIGHT(A2,3),RIGHT(B2,3))Fix mismatches caused by extra spaces
Use TRIM to remove leading and trailing ordinary spaces and reduce repeated ordinary spaces between words to a single space. To ignore those spacing differences while still checking capitalization, enter the following formula.
=EXACT(TRIM(A2),TRIM(B2))Use this only when those spacing differences should not count as changes. To ignore capitalization as well as the extra ordinary spaces, compare the trimmed values with the equality operator.
=TRIM(A2)=TRIM(B2)TRIM does not remove nonbreaking spaces by itself. If your comparison still reports a difference, check the remaining characters rather than assuming TRIM makes all visually similar text identical.
Highlight differences or repeated text
In Excel for Microsoft 365 or Excel 2024 on Windows, you can use conditional formatting to highlight row-by-row differences. Select A2:B100, then choose Home > Conditional Formatting > New Rule and select Use a formula to determine which cells to format.
Enter the following formula to highlight rows whose text differs, ignoring capitalization. Match the row number in the formula to the first row of your selected range.
=$A2<>$B2Select Format, choose a fill, and select OK, then confirm the rule. For differences that include capitalization, replace the comparison formula with this version.
=NOT(EXACT($A2,$B2))To highlight repeated text instead, select your comparison range and choose Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values. Choose the formatting and select OK. You can also use this duplicate highlighting path in current Mac editions.
Duplicate highlighting finds repetition anywhere in your selected range, including within either list, so it does not prove that corresponding rows match. The rule also treats * and ? as wildcard characters, so entries containing them can be highlighted as pattern matches rather than literal duplicates. If you plan to remove duplicates in Excel afterward, retain the original data first. You can copy a worksheet in Excel before removing records, since duplicate removal changes the data.
Return only the rows that differ
Use FILTER to place mismatched rows in a separate output area in Excel for Microsoft 365 and Excel 2024 on Windows and Mac. Select an empty cell with room for the results to expand, enter the following formula, and press Enter.
=FILTER(A2:B100,A2:A100<>B2:B100,"No differences")Your result includes rows where the corresponding cells in A and B differ, using a comparison that ignores capitalization. Replace <> with = to return matching rows instead, and adjust the ranges to cover your data.
Leave enough empty space for the returned rows to spill into surrounding cells. If you adapt this method to linked dynamic-array results between workbooks, keep both workbooks open.
Frequently Asked Questions
Can you compare several text cells at once?
In Excel for Microsoft 365 and Excel 2024 on Windows and Mac, or Excel for the web, use =AND(A2=B2,A2=C2) to check whether three cells match while ignoring capitalization. For a case-sensitive comparison, use =AND(EXACT(A2,B2),EXACT(A2,C2)).
How can you identify the character positions that differ?
In Excel for Microsoft 365 or Excel 2024 on Windows and Mac, put position numbers in C1 and the cells to its right. Enter =EXACT(MID($A2,C$1,1),MID($B2,C$1,1)) in C2 and copy across. FALSE identifies a position where the characters differ.
Does matching text length mean two cells contain the same text?
No, equal character counts do not establish that the text is identical. In Excel for Microsoft 365 or Excel 2024 on Windows and Mac, use =LEN(A2)=LEN(B2) to compare character counts. Use =LEN(A2)-LEN(B2) to show the difference in length.
Why might you need different function names or formula separators?
Your localized version of Excel may require different function names or separators. These examples use English function names and commas, so adapt those parts to your Excel language and regional setup.
How can you find a matching entry and return text beside it?
In Excel for Microsoft 365, Excel 2024 or Excel 2021 on Windows and Mac, use =XLOOKUP(A2,$B$2:$B$100,$C$2:$C$100,"Not found",0). It finds A2 in column B and returns the corresponding value from column C. XLOOKUP is unavailable in Excel 2016 and Excel 2019.