Function 01: EXACT

The 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 they're not exactly the same, the result is FALSE.

 

How Could You Use It?

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

EXACT Syntax

The EXACT function has the following syntax:

  • 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. In Excel 2007, the maximum string length for EXACT is 32767 characters.

EXACT Traps

In Excel 2007 Help, there is the following statement in the Remarks section for the EXACT function.

"You can also use the double equals (==) comparison operator instead of the EXACT function to make exact comparisons. For example, =A1==B1 returns the same value as =EXACT(A1,B1)."

This is incorrect. There is no "double equals" operator in Excel, and this remark has been removed in the Excel 2010 Help.

Example 1: Test a Password

You've entered a secret password in a cell in your workbook, and you named that cell "pwd". Users will enter a password, and you'll compare their entry to the contents of the "pwd" cell.

  • 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.

 

On another sheet, users will enter the password, and you'll use the EXACT function to test it.

  • On the Ex01 sheet, the user 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.

 

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

 

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)

 

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))

 

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 an Exact Match in a 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.

 

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 a Name for an Exact Match in a 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.

 

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))}

 

DWorld Group
On Line Admission
Result in MSExcel
Admission Form in PDF
Map Location
Max Maya Free Autocadd course ke sath
Offers
 
This is a free homepage created with page4. Get your own on www.page4.com
 
Excel School 0