EXACT Function in Excel

Sumit Bansal
Written by

Sumit Bansal is the founder of TrumpExcel.com and a 13-time Microsoft Excel MVP. He started this site in 2013 to share his passion for Excel through easy tutorials, tips, and training videos, helping you master Excel, boost productivity, and maybe even enjoy spreadsheets!

Last updated

The EXACT function checks whether two text values are exactly the same, including uppercase and lowercase letters, and returns TRUE or FALSE. It’s the function to use when “SAVE20” and “save20” should count as two different things.

That matters because most of Excel’s comparisons don’t care about case. The equal sign, COUNTIF, and XLOOKUP all treat those two codes as the same value.

In this tutorial, I’ll show you how EXACT works with text, spaces, and numbers, and how to use it for case-sensitive counts and lookups.

Follow along with the example file

EXACT Function Examples.xlsx

Download

EXACT Function Syntax

Here is the syntax of the EXACT function:

=EXACT(text1, text2)
  • text1 – The first text value you want to compare. It can be text in double quotes, a cell reference, or a range of cells.
  • text2 – The second text value, the one you want to compare with text1.

EXACT returns TRUE only when both values have the same characters, in the same order, with the same case. So “Excel” and “excel” return FALSE, and so does a value with an extra space anywhere in it.

The EXACT function works in all Excel versions, including Microsoft 365, Excel 2024, 2021, 2019, 2016, and Excel for Mac.

When to Use the EXACT Function

Use this function when you need to:

  • Check whether two lists match exactly, including uppercase and lowercase letters
  • Check answers or entries where case matters, such as codes and symbols
  • Make sure text was typed in uppercase
  • Find mismatches caused by extra spaces
  • Count or look up values with a case-sensitive match

Let me show you a few practical examples of how to use the EXACT function in Excel.

Example 1: Compare Two Columns for an Exact Match

Let’s start with a simple example.

Below is a list of brand names written the correct way and the same names as someone typed them into a product catalog, and I want to check whether each pair matches exactly in column C.

Brand names written correctly next to the same names as typed in a product catalog, beside an empty Exact Match column

Here is the formula:

=EXACT(A2:A11,B2:B11)
EXACT returns TRUE for each brand typed exactly right and FALSE for ones like Playstation and Lego

The formula compares each name in A2:A11 with the name next to it in B2:B11 and spills TRUE or FALSE down column C. You enter it only once, in C2.

Look at row 3, where PlayStation was typed as Playstation. The two look almost the same, but one lowercase “s” is enough for EXACT to return FALSE.

Spilling a range like this needs Excel 365 or Excel 2021 and later. If you are using Excel 2019 or earlier, enter the below formula in cell C2 and then copy it down the range:

=EXACT(A2,B2)

The same single-cell approach works for every spilling formula in this article.

TRUE and FALSE do the job, but a word like Match or Mismatch is easier to read when you share the sheet with someone. You can get that by wrapping EXACT inside the IF function.

Here is the formula that shows a label in column D:

=IF(EXACT(A2:A11,B2:B11),"Match","Mismatch")
IF with EXACT shows Match or Mismatch for each brand name in column D

EXACT does the comparison, and IF turns each TRUE into Match and each FALSE into Mismatch.

Example 2: EXACT vs the Equal Sign (Case-Sensitive Comparison)

Now let’s see why you need EXACT when the equal sign seems to do the same job.

Below is a student’s chemistry quiz with the correct symbol for each element and the answer the student wrote, and I want to check the answers with the equal sign in column D and with EXACT in column E.

A chemistry quiz with the correct element symbols and a student's answers, beside empty Equal Sign Check and EXACT Check columns

Here is the formula using the equal sign:

=B2:B11=C2:C11
The equal sign returns TRUE for all ten answers, even Co vs CO, because it ignores case

The equal sign returns TRUE for every row, so it says the student got all ten right. That’s because the equal sign ignores case, so it sees Co and CO as the same text.

In chemistry, that’s a real mistake, since Co is cobalt and CO is carbon monoxide.

Now here is the formula using EXACT:

=EXACT(B2:B11,C2:C11)
EXACT returns FALSE for the five answers written in the wrong case

EXACT returns FALSE for the five answers written in the wrong case (NA, CO, ca, k, and AG). So the student actually got five out of ten right.

Example 3: Check If Text Is in Uppercase

Here’s another practical scenario.

Below is a customer list where some state abbreviations were typed in lowercase or mixed case, and I want to check whether each state code is in uppercase in column D.

A customer list with some state codes typed in lowercase or mixed case, beside an empty Is Uppercase column

Here is the formula:

=EXACT(C2:C11,UPPER(C2:C11))
EXACT with UPPER returns FALSE for the state codes that are not fully uppercase, like tx and nV

The UPPER function converts each state code to uppercase, and EXACT compares that with the original. If the code was already in uppercase, the two match and you get TRUE.

Codes like tx, Id, and nV change when converted, so EXACT returns FALSE for them. You can use the same idea with the LOWER or PROPER function to check for lowercase or proper case.

Pro Tip: To stop codes that aren’t in uppercase from being entered at all, select C2:C11, go to Data > Data Validation, choose Custom, and enter =EXACT(C2,UPPER(C2)) as the formula.

Example 4: Find Mismatches Caused by Extra Spaces

Extra spaces are one of the most common reasons two values that look the same don’t match.

Below is a list of names from an RSVP form and the same guests from a guest list, and I want to check whether each pair matches exactly in column C.

Names from an RSVP form next to the same guests on a guest list, beside an empty Exact Match column

Here is the formula:

=EXACT(A2:A11,B2:B11)
EXACT returns FALSE for the names with extra spaces and for sarah miller in lowercase

EXACT returns FALSE for four names. Three of them have extra spaces, which EXACT counts as characters: a trailing space you can’t see after Emily Carter in A2, a leading space before Olivia Brooks in A4, and a double space in Sophia Reed in A6.

The fourth one, sarah miller in A8, is a case difference, not a space problem.

To ignore the extra spaces, you can wrap both ranges in the TRIM function.

Here is the formula:

=EXACT(TRIM(A2:A11),TRIM(B2:B11))
With TRIM inside EXACT, the three names with extra spaces now match and only sarah miller stays FALSE

TRIM removes the leading and trailing spaces and cuts double spaces between words down to one, before EXACT compares the names. So the three rows with space problems now return TRUE.

Row 8 still returns FALSE, because TRIM only fixes spaces and sarah miller is still in lowercase. That’s what you want when the case matters.

Example 5: How EXACT Compares Numbers and Text

EXACT is meant for text, but you can use it on numbers too, and the result can surprise you.

Below is a price list with the supplier’s price and the price in a store’s system for each item, and I want to check whether the two prices match in column D.

Supplier prices and store system prices for grocery items, some stored as text, beside an empty Exact Match column

Here is the formula:

=EXACT(B2:B11,C2:C11)
EXACT matches prices regardless of formatting or text storage, and returns FALSE for Coffee and the hidden-decimal Cheddar price

EXACT ignores cell formatting, so $2.99 in B3 matches 2.99 in C3, even though only one of them shows a dollar sign.

The left-aligned prices in C2, C4, and C7 are numbers stored as text, which often happens with imported data. EXACT still returns TRUE for them, while the equal sign would return FALSE because it sees a number and text as different values.

Row 6 is a real price difference, $8.99 against 9.49, so FALSE is the right answer there.

Row 8 is the tricky one. The Cheddar price in B8 shows $5.50, but the cell actually holds 5.499, so EXACT returns FALSE.

Important: EXACT compares the value stored in the cell, not the formatted number you see. If your prices have hidden decimals, round them with the ROUND function before you compare them.

Example 6: Case-Sensitive Count With EXACT and SUMPRODUCT

Let’s step it up with a case-sensitive count.

Below is a list of online orders with the promo code each customer entered, and the store only accepts the code in uppercase. I want to count how many orders used the code in D2 exactly as written, with the result in E2.

Online orders with the promo code each customer entered, and SAVE20 in D2 as the valid code

Here is the formula:

=SUMPRODUCT(--EXACT(B2:B13,D2))
SUMPRODUCT with EXACT counts 5 orders that used SAVE20 in exactly the right case

The formula returns 5.

How this formula works:

  • EXACT(B2:B13,D2) compares every promo code in B2:B13 with SAVE20 in D2 and returns an array of TRUE and FALSE values.
  • The double minus (–) converts each TRUE to 1 and each FALSE to 0.
  • SUMPRODUCT adds up those 1s and 0s, which gives you the number of exact matches.

The COUNTIF function would return 9 here, because it ignores case and also counts save20 and Save20.

SUMPRODUCT handles the array on its own, so this formula works in every Excel version, including Excel 2019 and earlier.

Example 7: Case-Sensitive Lookup With XLOOKUP and EXACT

Finally, let’s do a case-sensitive lookup.

Below is a list of gift card codes with their balances, where some codes differ only in case, and I want to get the balance for the code in D2 in cell E2.

Gift card codes and balances where some codes differ only in case, with gf7kq2 in D2 as the code to find

Here is the formula:

=XLOOKUP(TRUE,EXACT(A2:A11,D2),B2:B11)
XLOOKUP with EXACT returns $100, the balance of gf7kq2, not the $25 of GF7KQ2

The formula returns $100, the balance of gf7kq2 in row 3.

How this formula works:

  • EXACT(A2:A11,D2) compares the code in D2 with every code in A2:A11 and returns TRUE only for the one with the same case.
  • XLOOKUP looks for TRUE in that array and returns the balance from the same row in B2:B11.

A regular XLOOKUP with D2 as the lookup value would return $25 instead. It ignores case, so it stops at GF7KQ2 in row 2, which is a different gift card.

If no code matches exactly, the formula returns #N/A. To show a message instead, add it as the fourth argument of XLOOKUP, such as “Not found”.

XLOOKUP needs Excel 365 or Excel 2021 and later. If you are using Excel 2019 or earlier, enter the below formula in cell E2 and press Ctrl + Shift + Enter instead of Enter:

=INDEX(B2:B11,MATCH(TRUE,EXACT(A2:A11,D2),0))

Without Ctrl + Shift + Enter, older versions return #N/A for this formula.

So these are some practical ways to use the EXACT function in Excel. Whenever uppercase and lowercase letters matter in your data, EXACT is the function to reach for.

I hope you found this Excel tutorial useful.

List of All Excel Functions

Other Excel Articles You May Also Like:

Sumit Bansal

Sumit Bansal

13x Microsoft Excel MVP

Hey! I'm Sumit Bansal, founder of trumpexcel.com and a Microsoft Excel MVP. I started this site in 2013 because I genuinely love Microsoft Excel (yes, really!) and wanted to share that passion through easy Excel tutorials, tips, and Excel training videos. My goal is straightforward: help you master Excel skills so you can work smarter, boost productivity, and maybe even enjoy spreadsheets along the way!

Get the FREE 51 Excel Tips Ebook

Enter your details and the free PDF is on its way to your inbox.

Hmm, that didn't go through. Please check your email and try again.

No spam. You'll also get my weekly Excel newsletter. Unsubscribe anytime.

Check your inbox!

The ebook is on its way to your email. It usually lands within a couple of minutes.