Excel Text Equals: How to Compare Text Values in Cells

How-to basics · Updated November 18, 2026

In Excel, use the equals sign in a formula to check whether two text values match: with the text values in A2 and B2, enter =A2=B2. Excel returns TRUE if they match and FALSE if they do not; this comparison is not case-sensitive, so “North” and “NORTH” count as equal.

What “text equals” means in Excel

“Excel text equals” usually means comparing words, labels, codes, or other text stored in cells. The comparison operator is the equals sign (=), used inside a formula. It is different from typing text into a cell: a cell containing the word “equals” is just text, not a comparison.

A comparison formula returns a logical value: TRUE or FALSE. You can use that result directly, or make it more readable with a label. For example, with the values to compare in A2 and B2, enter =IF(A2=B2,"Match","Different"). If A2 contains “North” and B2 contains “South,” the result is “Different.” IF checks the comparison and returns the first label when it is true, or the second when it is false.

You can also compare a cell with a typed text value. With a status in A2, enter =A2="Open". The text being checked must be enclosed in straight double quotation marks. The formula returns TRUE when A2 contains Open, regardless of capitalization, and FALSE when it contains another value. This is useful for checks in reports, status columns, and simple validation formulas.

How the equals operator compares text

In a formula, Excel evaluates the two sides of the equals sign and then compares their values. In =A2=B2, the first equals sign begins the formula and the second is the comparison operator. The result is a logical value rather than a copy of either cell’s text.

By default, Excel’s ordinary text comparison ignores capitalization. It still takes the characters and spaces into account: “Maple” and “maple” compare as equal, while “Maple” and “Maple ” (with a trailing space) do not. A spelling difference, punctuation mark, or extra space can therefore make a comparison return FALSE even when the values look similar on the screen.

Comparison formulas are useful beyond displaying a result. You can use them inside IF, count matches, or make a conditional-formatting rule. For instance, comparing two columns row by row can flag records where an entered value differs from a reference value. It helps to decide whether you need a simple, case-insensitive match or a stricter comparison before choosing a formula.

When to use EXACT for capitalization

Use EXACT when uppercase and lowercase letters must be treated as different. Unlike the equals operator, EXACT is case-sensitive. With the text values in A2 and B2, enter =EXACT(A2,B2). If A2 contains “North” and B2 contains “NORTH,” the result is FALSE. If both contain “North” with the same characters and spacing, the result is TRUE.

EXACT is helpful for comparing product codes, identifiers, or text where capitalization is meaningful to your process. It also checks spaces, so “ID7” and “ID7 ” are not an exact match. It does not remove formatting or repair text; it simply reports whether the two strings match exactly, including case.

To return words instead of TRUE or FALSE, you can put EXACT inside IF. With the values in A2 and B2, enter =IF(EXACT(A2,B2),"Exact match","Not exact"). This formula reports “Not exact” for differences in capitalization or spacing. If capitalization does not matter, use the ordinary equals operator inside IF instead.

Spaces and invisible characters that cause mismatches

Extra spaces are a frequent reason a comparison appears wrong. A leading space before a name or a trailing space after it is easy to miss in a narrow cell. Ordinary spaces between words also matter, so “New York” is not the same text as “NewYork.” If you want to ignore unnecessary ordinary spaces, TRIM can normalize each value before comparing.

With the values to compare in A2 and B2, enter =TRIM(A2)=TRIM(B2). If A2 contains “ North ” and B2 contains “North,” the formula returns TRUE. TRIM removes leading and trailing ordinary spaces and reduces repeated spaces between words to one. Because it also changes repeated internal spaces, use it only when those differences should not count.

Copied text from websites or other systems may include a nonbreaking space, which can look like an ordinary space but is not removed by TRIM alone. CLEAN removes certain nonprinting ASCII characters, and SUBSTITUTE can replace the nonbreaking space represented by CHAR(160). With the two values in A2 and B2, enter =TRIM(CLEAN(SUBSTITUTE(A2,CHAR(160)," ")))=TRIM(CLEAN(SUBSTITUTE(B2,CHAR(160)," "))). The result is TRUE when the values match after those specific cleanup steps.

That cleanup formula is not a universal text repair tool. CLEAN targets certain nonprinting characters, while SUBSTITUTE here handles character 160; other unusual Unicode characters may need separate investigation. If a match still fails, compare the source values, inspect their lengths, or paste them into a plain-text editor to look for unexpected characters.

Text values, numbers, and blank cells

Text that looks like a number can behave differently from a numeric value. For example, a cell may contain the number 007 as text to preserve a leading zero, while another cell contains the number 7. Decide whether those represent the same identifier in your data. If leading zeros matter, preserve and compare the entries as text; converting them to numbers can remove those zeros.

Do not assume that every value displayed as text is stored as text. A number may have a custom number format, while a text string may only look numeric. You can inspect a cell’s type with a function. With the value in A2, enter =ISTEXT(A2); Excel returns TRUE if A2 contains text and FALSE otherwise. This can help diagnose a mismatch before changing data types.

Blank cells need similar care. A genuinely empty cell is not quite the same thing as a formula that displays an empty string, such as a formula returning "". A check such as =A2="" can identify both as appearing empty, so it is not a reliable way to tell which kind of blank you have. With the cell to inspect in A2, enter =ISBLANK(A2). It returns TRUE for a genuinely empty cell and FALSE if A2 contains a formula, even when that formula displays nothing.

Compare many values and highlight matches

For a straightforward row-by-row check, put the comparison formula beside the data and fill it down. With pairs of values in columns A and B beginning in row 2, enter =A2=B2 in C2, then copy or fill the formula down column C. Each row will show TRUE or FALSE for its own pair. This makes it easier to filter for mismatches or review a long list without comparing cells manually.

To highlight matching or different rows visually, select the intended output cells and use a conditional-formatting formula. For example, with the values to compare in columns A and B, and the rule applied to C2:C100, use =$A2=$B2 as the rule formula. It returns TRUE for a row when the two values match under Excel’s ordinary case-insensitive comparison. The dollar signs lock the column references while the row number adjusts for each row.

In Excel for Microsoft 365 on Windows, select the cells to format, then choose Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format. Enter the comparison formula, choose a format, and confirm. On Mac, the Conditional Formatting controls are also on the Home tab, though their placement can vary by window size and build. The formula’s behavior is the same.

If you only need to find repeated values in one selected range, Excel also has a built-in Duplicate Values rule: select the range and choose Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values. That checks for duplicates within the selected range; it is not a substitute for comparing two specific cells row by row.

Choose the right comparison and troubleshoot results

Use the simplest method that matches the rule you intend to apply:

  • Use =A2=B2 for a normal text comparison where capitalization does not matter.
  • Use =EXACT(A2,B2) when capitalization must match exactly.
  • Use TRIM around the cell references when ordinary extra spaces should be ignored.
  • Use a cleanup step for known invisible characters rather than assuming every mismatch is a capitalization issue.

If Excel returns an unexpected result, check the basics before changing the formula:

  • Click each source cell and inspect the formula bar for spaces or punctuation that are not obvious in the grid.
  • Check whether one entry is stored as a number and the other as text, especially for codes with leading zeros.
  • Try EXACT to determine whether capitalization is the only difference, or compare TRIM results if spaces are suspected.
  • Confirm that the formula references the intended row and columns, particularly after copying it down.
  • Check for copied nonbreaking spaces or other invisible characters when ordinary cleanup does not fix the comparison.

A common misconception is that the equals operator checks whether two cells look identical on screen. It compares their underlying values according to Excel’s comparison rules, not their font, color, number format, or column width. Two cells can look the same but contain different text; conversely, text with different capitalization can compare equal with =. Choose EXACT or a deliberate cleanup step when the default comparison does not match your definition of “equal.”

Frequently Asked Questions

Is Excel text comparison case-sensitive?
No. The ordinary equals operator treats uppercase and lowercase as equal. Use EXACT if capitalization must match.

How do I check whether a cell equals specific text?
With the value in A2, enter =A2="Open" to check whether it equals Open. The result is TRUE or FALSE, and the normal comparison ignores capitalization.

Why does Excel say two identical-looking words are different?
One value may contain a leading or trailing space, a nonbreaking space, or another invisible character. Inspect the source text and use suitable cleanup only when those differences should be ignored.

Does TRIM make a comparison case-sensitive?
No. TRIM changes ordinary spacing; it does not change the case rules of the equals operator. Wrap the cleaned values in EXACT if you need both spacing cleanup and a case-sensitive comparison.

Can I compare text across two worksheets?
Yes. A formula can refer to cells on another worksheet, provided you use the sheet reference in the cell reference. The same comparison rules apply: the ordinary equals operator is not case-sensitive, and EXACT is case-sensitive.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.