Contextures

Compare Cells with Excel EXACT Function Examples

Use the Excel EXACT function to compare text strings for an exact match, including upper and lower case. There are 7 examples for how to use EXACT, with video and written steps.

Author: Debra Dalgleish

Introduction: Excel EXACT Function

The Excel EXACT function can check for an exact match between text strings, including upper and lower case. Formatting does not affect the result.

  • If the text strings are exactly the same, the function result is TRUE
  • If the text strings are NOT exactly the same, the result is FALSE

exact function compare cells

Video: Excel EXACT Function

To see the examples in the EXACT function sample workbook, watch this Excel video tutorial.

There are written steps for each example, in the sections below the video.

How Could You Use EXACT Function?

Besides checking two cells to see if their contents match exactly, you can use the EXACT function to do the following:

  • Use with data validation to block changes to a cell
  • Force upper case entries in a data validation cell
  • Check for an exact match in a list of codes
  • Find an exact match in a lookup table
  • Count exact matches in a list
  • Pinpoint the differences between 2 cells

There are step-by-step examples in the sections below.

EXACT Function Syntax

The EXACT function has the following syntax for its arguments:

  • EXACT(text1,text2)
    • Text1 is the first text string.
    • Text2 is the second text string.

You can enter the text1 and text2 arguments as cell references or text strings.

The maximum string length for EXACT is 32767 characters.

Example 1: Test a Password

In this example, there is a secret password entered in a cell in an Excel workbook, That cell has been named as “pwd”.

  • In the screen shot below, the secret password is in cell C2, which is named “pwd”.
  • This is on a sheet named AdminData, which can be hidden from users.

exact function compare passwords

On another sheet, people will enter a password, and there is a cell with the EXACT function, to test if the password is an exact match for the correct password.

  • On the Ex01 sheet, people will type a password in cell C3.
  • In cell C4, the equal operator compares the value in C3 to the value in the pwd cell: = C3=pwd
  • In cell C5, the EXACT function compares C3 to the pwd cell, including case: =EXACT(C3,pwd)

If the contents of the two cells are identical, including upper and lower case, cell C5 will show TRUE as the result. Any formatting differences, such as bold font, will be ignored.

passwords are exact match

If there is a difference in the contents – if even one letter is a different case, the result in C5 will be FALSE.

passwords are not exact match

Example 2: Allow Changes to a Cell

After the user enters the correct password, you could allow changes to specific cells in the worksheet. For example, a custom data validation formula in cell C5 could control changes to the Daily Rate.

With the following formula in the data validation dialog box, users can enter a value in cell C5 only if the password typed in C3 is an exact match for the secret password in the pwd cell. Also, the value typed in C5 must be higher than zero, and lower than 0.1.

=AND(EXACT(C3,pwd),C5>0,C5<0.1)

data validation allow changes

Example 3: Force Upper Case Entries

You could also use the EXACT function in data validation to ensure that all upper case letters are typed in a cell. For example, a Canadian postal code is a set format, with alternating numbers, and upper case letters, e.g., L9L 9L9.

In cell C2, data validation has been applied, with the formula:

EXACT(C2,UPPER(C2))

Force Upper Case Entries

If any lower case letters are entered, an error alert will appear. This won’t prevent all errors in the postal code, but will ensure that upper case letters are used.

Example 4: Find Exact Match in List

Instead of simply comparing one cell to another, you might need to look for an exact match in a list of values. If someone types a product code in a cell, is that exact code in your product list?

In this example, there is a product code list in cells B2:B5, and a customer can order a product, by typing its code in cell E2.

Find Exact Match in List

The formula in cell F2 uses the EXACT function to check the code typed in cell E2, and see if there’s an exact match in the list of product codes.

NOTE: The formula is array entered, by pressing Ctrl+Shift+Enter
{=OR(EXACT($B$2:$B$5,E2))}

Example 5: Pull Name for Exact Match in List

In a lookup table, the EXACT function can distinguish between AA1 and Aa1, and help return the correct product name for each code. Other functions, like VLOOKUP, would treat those codes as identical, and return the product name for the first code it encounters in the table.

In this example, there is a product code list in cells B2:B5, and a customer can order a product, by typing its code in cell D2.

Pull Name for Exact Match in List

The formula in cell E2 uses 3 functions – INDEX, MATCH and EXACT:

  • The EXACT function checks the code typed in cell D2, and see if there’s an exact match in the list of product codes.
  • The MATCH function returns the table row number of the TRUE result, and bG8943TO is found in the 2nd row of the range.
  • The INDEX function returns the value in the 2nd row of the range A2:A5 – Sam.

NOTE: The formula is array entered, by pressing Ctrl+Shift+Enter
{=INDEX($A$2:$A$5,MATCH(TRUE,EXACT($B$2:$B$5,D2),0))}

Example 6: Count Exact Matches in List

In a lookup table, the EXACT function can distinguish between AA1 and Aa1, and help return the correct count for each code. Other functions, like COUNTIF, would treat those codes as identical, and return the count for all variations of the code.

In this example, there is a Item list in cells A2:A11, and a list of unique items in column C.

Count Exact Matches in List

The formula in column D uses 2 functions – SUMPRODUCT and EXACT:

  • The EXACT function checks the item typed in column C, and see if there’s an exact match in the list of items.
  • The SUMPRODUCT function returns the total count, based on the number of TRUE results.

=SUMPRODUCT(–EXACT($A$2:$A$11,C2))

Note: The two minus signs (double unary) in front of the EXACT function convert the TRUE and FALSE values to 1 and 0 values.

exact function with sumproduct

Example 7: Check Each Character in Cell

The EXACT function can tell you if two text strings match exactly, but you might want a quick way to see which characters are not identical. In this example, each string has 6 characters, and the numbers 1 to 6 are entered as column headings.

Check Each Character in Cell

The formula in cell E2 uses 3 functions – MID and EXACT:

  • The MID function returns a specific character from column A or column B, based on the number in the formula’s column heading. For example, in the formula shown above, for C2, the first character in each string is tested, because the number in cell C1 is 1.
  • The EXACT function compares the two characters extracted by the MID functions.

=EXACT(MID($A2,C$1,1),MID($B2,C$1,1))

Download the Workbook

EXACT Function Examples: Download the sample file with EXACT examples from this tutorial. The zipped Excel file is in xlsx format, and does not contain macros.

Related Tutorials

Compare Cell Values

VLOOKUP Troubleshooting

INDEX / MATCH Functions

INDIRECT function

EXACT Function Examples

Last updated: April 12, 2022 3:22 PM