Skip to content

EXACT

Checks whether two pieces of text are identical, including capital letters. Returns TRUE or FALSE.

Syntax

=EXACT(, )

Text

All versions of Excel.

Try it

Edit the formula in C2 or change the inputs. The sheet recalculates as you type.

C2
A
B
C
1
Entered
Master
EXACT
2
fx-1010
FX-1010
FALSE
3
4

C2 =EXACT(A2,B2) returns FALSE

How EXACT works

EXACT compares two pieces of text and returns TRUE only if they are identical, character for character, including upper and lower case. Use it when the difference between FX-1010 and fx-1010 matters: passwords, case-sensitive codes, and checks for duplicates that differ only in case.

How it differs from =

Excel's = operator ignores case. ="FX-1010"="fx-1010" returns TRUE. EXACT returns FALSE for the same pair. For everything else, the two behave alike: if the text differs in any other way, a different letter, a space, a dash, both give FALSE.

EXACT ignores formatting. Bold, colour and number formats make no difference. It compares the stored values, so a cell showing 1,250 because of a number format and a cell holding the text 1250 are compared as 1250 and 1250, and EXACT says TRUE. A number and the same number as text also compare as equal.

Spaces count

A trailing space makes text different. =EXACT("FX-1010","FX-1010 ") returns FALSE. If EXACT unexpectedly returns FALSE for text that looks the same, wrap both sides in TRIM, or compare lengths with LEN to find the hidden difference.

Counting exact matches in a range

EXACT accepts a range, so it can test a whole list at once. Combined with SUMPRODUCT it counts case-sensitive matches: =SUMPRODUCT(--EXACT(A2:A9,"FX-1010")) counts the cells equal to FX-1010 in capitals. The double minus turns TRUE and FALSE into 1 and 0. COUNTIF would count fx-1010 as well, because it ignores case.

Case-sensitive lookups

Lookup functions ignore case, so to find a value case-sensitively, use EXACT as the test. In Microsoft 365: =XLOOKUP(TRUE,EXACT(A2:A9,E2),B2:B9). EXACT builds an array of TRUE and FALSE, and XLOOKUP looks for the first TRUE. In older versions, INDEX and MATCH can do the same: =INDEX(B2:B9,MATCH(TRUE,EXACT(A2:A9,E2),0)), entered with Ctrl+Shift+Enter.

Highlighting and validation

In a conditional formatting rule or data validation, EXACT lets you flag entries that differ from a master value only in case. Anything that must match a reference code exactly can use =EXACT(A2,$E$1) as its test.

Related ideas

FIND and SUBSTITUTE are also case-sensitive, but they search within text. EXACT compares whole values. If you want to compare without caring about case, use = or convert both sides with LOWER.

Arguments

text1
The first piece of text, usually a cell such as A2.
text2
The second piece of text to compare with the first, usually a cell or a value in quotes.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Case matters: = and EXACT disagree

C2 =EXACT(A2,B2)

Result: FALSE

The codes differ in case only. The = operator would say TRUE, but EXACT is strict and returns FALSE.

C2
A
B
C
1
Entered
Master
EXACT
2
fx-1010
FX-1010
FALSE
3
4

C2 =EXACT(A2,B2) returns FALSE

Example 2

Identical text returns TRUE

C2 =EXACT(A2,B2)

Result: TRUE

Every character, including the case, matches.

C2
A
B
C
1
Entered
Master
EXACT
2
FX-1010
FX-1010
TRUE
3
4

C2 =EXACT(A2,B2) returns TRUE

Example 3

A trailing space makes text different

C2 =EXACT(A2,B2)

Result: FALSE

A2 has a space at the end. EXACT sees it, and so does a lookup. EXACT(TRIM(A2),B2) would return TRUE.

C2
A
B
C
1
Entered
Master
EXACT
2
FX-1010
FX-1010
FALSE
3
4

C2 =EXACT(A2,B2) returns FALSE

Example 4

Count exact, case-sensitive matches

D2 =SUMPRODUCT(--EXACT(A2:A5,"FX-1010"))

Result: 2

EXACT tests every cell in A2:A5, and SUMPRODUCT adds the TRUE results. COUNTIF would return 3 because it ignores case.

D2
A
B
C
D
1
Entered code
Qty
Exact FX-1010
2
FX-1010
12
2
3
fx-1010
8
4
FX-1010
30
5
FX-1085
5
6
7

D2 =SUMPRODUCT(--EXACT(A2:A5,"FX-1010")) returns 2

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In C2, return TRUE if the code in A2 exactly matches the master code in B2, including case, and FALSE otherwise. Fill it down to C5.

Answer in C2, then it fills down to C5.

C2
A
B
C
D
1
Entered
Master
Exact match?
Log
2
FX-1010
FX-1010
FX-1010
3
fx-1085
FX-1085
fx-1010
4
FX-2040
FX-2040
FX-1010
5
FX-3012
FX-3O12
FX-1085
6
7
Entries of FX-1010 in capitals
8

Common mistakes

  • EXACT is stricter than you may expect. Differences in case, spaces and punctuation all give FALSE. If it surprises you, compare LEN of both sides.
  • EXACT ignores formatting but not stored values. A number and the same number as text, such as 1250 and "1250", are compared as equal.
  • For a case-insensitive comparison, use = instead. EXACT is only needed when case matters.
  • EXACT compares two values. To test a list, wrap it in SUMPRODUCT or use it inside XLOOKUP. A bare range gives an array of results, not a single answer.
  • EXACT does not support wildcards. For partial matches, use SEARCH or FIND.

Questions people ask

How do I compare text in Excel with case sensitivity?

Use `=EXACT(A2,B2)`. It returns TRUE only when the text is identical, including capitals. The `=` operator ignores case.

What is the difference between EXACT and =?

Both return TRUE or FALSE. The = operator ignores upper and lower case, so "ABC"="abc" is TRUE. EXACT is case-sensitive, so EXACT("ABC","abc") is FALSE.

How do I do a case-sensitive lookup?

In Microsoft 365, `=XLOOKUP(TRUE,EXACT(A2:A9,E2),B2:B9)`. EXACT produces TRUE for the case-sensitive match, and XLOOKUP finds that TRUE. VLOOKUP and MATCH on their own ignore case.

How do I count case-sensitive matches?

Use `=SUMPRODUCT(--EXACT(A2:A9,"FX-1010"))`. COUNTIF and COUNTIFS ignore case.

Why does EXACT return FALSE for text that looks the same?

There is probably a hidden difference: a trailing space, a non-breaking space, or a different letter case. Compare `LEN(A2)` and `LEN(B2)`, and try `EXACT(TRIM(A2),TRIM(B2))`.

Learn EXACT in a real sheet.

EXACT is taught in Logic and text, lesson 8: PROPER, UPPER and LOWER. Each lesson is a short, graded exercise like the one above.