EXACT Function: Case‑Sensitive Comparisons & Data Validation

Learn how to use Excel's EXACT function for case-sensitive text comparisons, data validation rules, case-sensitive VLOOKUP alternatives.
Excel’s equals operator treats “APPLE” and “apple” as identical — which is correct most of the time but wrong when case is meaningful. Product codes, status flags, and reference IDs often need an exact case match. The EXACT function compares two text strings character by character and returns TRUE only when every letter matches precisely. This guide covers 8 practical patterns: basic comparisons, IF+EXACT audit labels, data validation rules that enforce uppercase or proper case, case-sensitive INDEX MATCH lookups, SUMPRODUCT counting without COUNTIF’s case-blindness, prefix validation with LEFT, and a three-way audit formula that separates case errors from content errors.

Excel's equals operator (=) is not case-sensitive. It treats "APPROVED", "Approved", and "approved" as identical — which is correct for most tasks, but wrong when case is meaningful. Product codes like "SKU-A1" and "sku-a1" should not match. Status values like "FINAL" and "Final" have different meanings in some workflows. The EXACT function is Excel's solution. It compares two text strings character by character, including case, and returns TRUE only when every character matches precisely.

Beyond basic comparisons, EXACT powers case-sensitive data validation rules, case-sensitive lookups, and case-sensitive counting — tasks that the standard equals operator, VLOOKUP, COUNTIF, and SUMIF cannot handle correctly on their own.

Availability: EXACT works in every Excel version from Excel 2000 onwards, including Microsoft 365, Excel 2024, 2021, 2019, and 2016. It also works in Google Sheets with identical syntax.

What Is the EXACT Syntax?

EXACT takes exactly two arguments — the two text strings to compare.

=EXACT(text1, text2)
ArgumentRequired?What it does
text1RequiredThe first text string to compare. Can be a cell reference, a hardcoded string in double quotes, or a formula result.
text2RequiredThe second text string to compare against text1. EXACT returns TRUE when both strings match exactly — same characters, same case, same length.

EXACT is case-sensitive but ignores cell formatting. It compares the stored value, not the displayed value. Consequently, a cell formatted to show "£1,000" but containing 1000 returns FALSE when compared to the text "£1,000" — the underlying values differ. Additionally, leading and trailing spaces count as differences, which makes TRIM an important companion function.

EXACT vs the Equals Operator — When Does It Matter?

The equals operator (=) and EXACT look similar but behave differently. Use EXACT whenever case is meaningful data — not just cosmetic. Use the equals operator for all other comparisons.

Comparison=A1=B1 result=EXACT(A1,B1) result
"apple" vs "apple"TRUETRUE
"apple" vs "APPLE"TRUE — ignores caseFALSE — case differs
"apple" vs "Apple"TRUE — ignores caseFALSE — case differs
"apple" vs " apple"TRUE — ignores spaceFALSE — space differs
"SKU-A1" vs "SKU-a1"TRUE — ignores caseFALSE — case differs
EXACT treats numbers and text differently: If A1 contains the number 100 and B1 contains the text "100", =A1=B1 returns TRUE (Excel coerces types). However, =EXACT(A1, B1) returns FALSE because the stored values are different data types. Always ensure both cells hold the same data type before using EXACT.

Examples 1–4: Core Comparisons and Labels

1
Basic case-sensitive comparison — product codes and reference IDs

Product codes, order IDs, and reference numbers are often case-sensitive. "SKU-A1" and "SKU-a1" should not match — but the equals operator treats them as identical. EXACT correctly flags the difference.

A — Expected
B — Entered
=A=B
=EXACT(A,B)
SKU-A1
SKU-A1
TRUE
TRUE ✓
SKU-A1
SKU-a1
TRUE — wrong!
FALSE ✓
REF-001
ref-001
TRUE — wrong!
FALSE ✓
Basic EXACT comparison — returns TRUE if both strings match including case: =EXACT(A2, B2) Compare against a hardcoded expected value: =EXACT(A2, "SKU-A1") → TRUE only if A2 contains exactly "SKU-A1" — not "sku-a1", not "Sku-A1" Add TRIM to handle hidden leading or trailing spaces: EXACT("apple", " apple") returns FALSE — the space is a real difference. Wrapping with TRIM removes the space before comparison. =EXACT(TRIM(A2), TRIM(B2))
2
IF + EXACT — return custom labels based on case-sensitive match

Wrapping EXACT in IF produces a readable label instead of TRUE or FALSE. This pattern is useful for audit columns, QC checklists, and status displays where "Match" and "Mismatch" are more meaningful than raw boolean values.

Return "Match" or "Mismatch" based on case-sensitive comparison: =IF(=EXACT(A2, B2), "Match", "Mismatch") Return a specific error type label — useful in data audit workflows: Flags whether the mismatch is a case error or a completely different value. =IF(=EXACT(A2, B2), "✓ Exact match", IF(A2=B2, "⚠ Case error only", "✗ Different value")) → "✓ Exact match" — both strings match perfectly → "⚠ Case error only" — same letters, wrong case → "✗ Different value" — content is different Flag mismatches for conditional formatting: Apply a red fill to the EXACT formula cell when it returns FALSE. =EXACT(A2, B2)=FALSE ← use this as a conditional formatting rule formula
3
Data validation — enforce that a cell must contain a specific exact string

Standard Excel data validation is case-insensitive — a list rule allows "approved", "APPROVED", and "Approved" equally. EXACT in a custom formula makes validation case-sensitive. Users must enter the value in precisely the correct case or they see an error message.

Step 1 — Select the cell or range to protect (e.g. D2:D100). Step 2 — Data tab → Data Validation → Allow: Custom. Step 3 — Enter this formula (D2 is the first cell in the selection): Require exactly "APPROVED" in all caps: Any other capitalisation — "Approved", "approved" — is rejected. =EXACT(D2, "APPROVED") Allow multiple exact values using OR: The user may enter "APPROVED" or "REJECTED" — both in uppercase only. =OR( =EXACT(D2, "APPROVED"), =EXACT(D2, "REJECTED"), =EXACT(D2, "PENDING")) Step 4 — Go to the Error Alert tab. Set Style: Stop. Enter a message like: "Invalid entry. Please type APPROVED, REJECTED, or PENDING in uppercase."
Set a clear Error Alert message: Without a custom error message, users see a generic Excel warning that does not explain what went wrong. Go to the Error Alert tab in Data Validation and write a message that states the exact format required — for example: "Please enter APPROVED in all capitals."
4
Data validation — enforce proper case input using EXACT + PROPER

Combining EXACT with PROPER creates a validation rule that enforces title case — first letter of every word capitalised, everything else lowercase. This is useful for customer name fields, city fields, or any column that must follow consistent capitalisation rules.

Enforce that input matches its own PROPER-case version. PROPER(C2) converts the input to proper case. EXACT then checks whether the input already equals the proper-case version. If they match, the user typed in proper case — validation passes. If they differ, the user typed in wrong case — validation blocks the entry. =AND( =EXACT(C2, PROPER(C2)), ISTEXT(C2)) "James Smith" → passes (matches PROPER version) "JAMES SMITH" → blocked (does not match PROPER version) "james smith" → blocked (does not match PROPER version) ISTEXT() ensures numbers cannot be entered in a name field. Enforce UPPERCASE input using EXACT + UPPER: Ensures values like reference codes are always entered in uppercase. =EXACT(C2, UPPER(C2)) "FINAL" → passes. "Final" → blocked. "final" → blocked. Enforce lowercase input using EXACT + LOWER: Useful for email address fields or username fields. =EXACT(C2, LOWER(C2)) "james@example.com" → passes. "James@example.com" → blocked.

Examples 5–8: Advanced Combinations

Case-Sensitive Lookups and Counting

Standard Excel lookup and count functions — VLOOKUP, XLOOKUP, COUNTIF, SUMIF — are not case-sensitive. They treat "Apple" and "APPLE" as identical. EXACT solves this by generating an array of TRUE/FALSE values that other functions can use to locate or count exact case matches.

5
Case-sensitive lookup — INDEX MATCH with EXACT

Nesting EXACT inside INDEX MATCH creates a fully case-sensitive lookup. EXACT returns an array of TRUE/FALSE values for each row. MATCH finds the first TRUE — which is the first row with an exact case-sensitive match. INDEX then retrieves the corresponding return value.

Data: column A holds product codes (some identical except for case). Column B holds prices. Look up "SKU-A1" — exact case, not "SKU-a1". EXACT(G1, A2:A100) returns an array: {TRUE,FALSE,TRUE,...} MATCH(TRUE, ..., 0) finds the first TRUE. INDEX retrieves the price for that row. =INDEX(B2:B100, MATCH(TRUE, =EXACT(G1, A2:A100), 0)) ← Ctrl+Shift+Enter in Excel 2019 and earlier Enter normally in Excel 365 XLOOKUP version (Excel 365 and 2021 only) — simpler syntax: EXACT inside the lookup_array argument makes it case-sensitive. XLOOKUP(TRUE, =EXACT(G1, A2:A100), B2:B100, "Not found") → Returns price for exact code match, "Not found" if no match

Case-Sensitive Counting with SUMPRODUCT

6
Case-sensitive count — SUMPRODUCT + EXACT

COUNTIF is not case-sensitive — it counts "apple", "Apple", and "APPLE" equally. SUMPRODUCT combined with EXACT fixes this. EXACT returns an array of TRUE/FALSE values. The double negative (--) converts them to 1s and 0s. SUMPRODUCT then sums the 1s, producing an exact case-sensitive count.

Count how many times "APPLE" (all caps) appears in A2:A100. COUNTIF would also count "Apple" and "apple" — wrong for case-sensitive data. EXACT+SUMPRODUCT counts only the exact-case match. =SUMPRODUCT(--(=EXACT("APPLE", A2:A100))) → Returns the count of cells containing exactly "APPLE" (uppercase only) The double negative (--) converts TRUE/FALSE to 1/0 for SUMPRODUCT to sum. Use a cell reference for the search value — more flexible for dashboards: G1 holds the exact string to count. =SUMPRODUCT(--(=EXACT(G1, A2:A100))) Case-sensitive SUMIF equivalent — sum values in B where A exactly matches G1: Multiply the TRUE/FALSE array by the values in B, then sum the products. =SUMPRODUCT(--(=EXACT(G1, A2:A100)) * B2:B100) → Sums column B only for rows where column A exactly matches G1 (case-sensitive)
7
Data validation — enforce a prefix with exact case using EXACT + LEFT

EXACT combined with LEFT validates that an entry begins with a specific exact prefix. This is useful for order IDs, reference codes, and file names where the prefix must be in a specific case format. "AA-001" is valid, but "aa-001" and "Aa-001" are not.

Require that cell A2 starts with exactly "AA-" (uppercase). LEFT(A2, 3) extracts the first three characters. EXACT checks if they match "AA-" exactly — case-sensitive. Apply in Data Validation → Allow: Custom → Formula: =EXACT(LEFT(A2, 3), "AA-") "AA-001" → passes. "aa-001" → blocked. "Aa-001" → blocked. Also check that the total length is correct — e.g. exactly 6 characters: Combines prefix check with length check for strict format enforcement. =AND( =EXACT(LEFT(A2, 3), "AA-"), LEN(A2)=6) "AA-001" (6 chars, correct prefix) → passes "AA-0001" (7 chars) → blocked — too long "BB-001" → blocked — wrong prefix
8
Audit trail — compare two lists and flag case-only differences

A three-way comparison using both the equals operator and EXACT distinguishes three types of differences: exact matches, case-only errors, and completely different values. This is particularly useful for data migration audits, where imported data often contains the right content but wrong capitalisation.

Column A = expected values (master list). Column B = imported data to verify. Three-way audit formula — classifies each row as one of three states: =IF(=EXACT(A2, B2), "✓ Exact match", IF(UPPER(A2)=UPPER(B2), "⚠ Case error", "✗ Different value")) → "✓ Exact match" — both identical including case → "⚠ Case error" — same letters, wrong case (e.g. "Apple" vs "APPLE") → "✗ Different value" — content differs completely Count the case errors across the whole audit range: SUMPRODUCT counts rows where UPPER matches but EXACT does not. =SUMPRODUCT( (UPPER(A2:A100)=UPPER(B2:B100)) * (--(=EXACT(A2:A100, B2:B100)=FALSE))) → Returns the number of rows with a case error (content OK, case wrong)
The three-way audit pattern is invaluable after a data migration or system import. It separates rows that need only a case correction from rows where the actual content is wrong — letting you prioritise the more serious errors first.

Common EXACT Issues and How to Fix Them

EXACT returns FALSE when strings look identical

The most common cause is invisible whitespace. A leading space, trailing space, or non-breaking space makes two strings appear identical on screen but different to EXACT. Wrap both arguments in TRIM before comparing: =EXACT(TRIM(A2), TRIM(B2)). Additionally, check whether one cell contains a non-breaking space (character code 160 from web-pasted content) — TRIM does not remove these. Use SUBSTITUTE to eliminate them first: =TRIM(SUBSTITUTE(A2, CHAR(160), " ")).

Data validation rule using EXACT is not working

Check that the cell reference in the formula matches the first cell of the selected validation range. Data validation formulas must reference the top-left cell of the selection. If your selected range is D2:D100, the formula must reference D2 — not D1 or an absolute reference like $D$2. The rule then applies relatively to every cell in the range.

EXACT + SUMPRODUCT returns zero when matches exist

Confirm that the double negative (--) is present before the EXACT call. Without it, SUMPRODUCT receives an array of TRUE/FALSE values rather than 1s and 0s, and returns zero. The correct pattern is =SUMPRODUCT(--(EXACT(G1, A2:A100))). Additionally, check that the range in EXACT matches the range in any other SUMPRODUCT arrays — mismatched range sizes return #VALUE!.

EXACT does not work inside standard COUNTIF or SUMIF: You cannot use EXACT as a criteria argument for COUNTIF, COUNTIFS, SUMIF, or SUMIFS — these functions do not accept EXACT as a criteria expression. Use the SUMPRODUCT + EXACT pattern from Example 6 instead, which achieves the same result without those functions.

Frequently Asked Questions

  • What does the EXACT function do in Excel?+
    EXACT compares two text strings and returns TRUE if they are identical in every character — including uppercase and lowercase letters. If the strings differ in any way, including case, it returns FALSE. For example, =EXACT("Apple", "apple") returns FALSE because the first letters differ in case. The standard equals operator (=A1=B1) is not case-sensitive and would return TRUE for the same comparison. EXACT is specifically for situations where case is meaningful data.
  • How do I make data validation case-sensitive using EXACT?+
    Select the cells you want to protect, go to Data → Data Validation, and in the Allow dropdown choose Custom. In the Formula box, enter a formula using EXACT that references the first cell in your selection. For example, to require exactly "APPROVED" in all caps, enter =EXACT(D2, "APPROVED"). To enforce proper case, enter =AND(EXACT(C2, PROPER(C2)), ISTEXT(C2)). Go to the Error Alert tab and add a clear message explaining the required format. The rule applies to every cell in your selected range.
  • How do I do a case-sensitive VLOOKUP or XLOOKUP with EXACT?+
    Standard VLOOKUP and XLOOKUP are not case-sensitive — they treat "Apple" and "APPLE" as identical. To make them case-sensitive, use INDEX MATCH with EXACT: =INDEX(B2:B100, MATCH(TRUE, EXACT(G1, A2:A100), 0)). EXACT returns an array of TRUE/FALSE values. MATCH finds the first TRUE — which is the first row with an exact case-sensitive match. In Excel 2019 and earlier this requires Ctrl+Shift+Enter. In Excel 365, XLOOKUP(TRUE, EXACT(G1, A2:A100), B2:B100, "Not found") is a cleaner alternative.

More Questions About EXACT

  • Does EXACT ignore spaces?+
    No. EXACT is sensitive to every character including spaces. A leading or trailing space makes two otherwise identical strings return FALSE. For example, =EXACT("apple", " apple") returns FALSE because of the leading space in the second string. Always wrap both arguments in TRIM before comparing if your data may contain extra whitespace: =EXACT(TRIM(A2), TRIM(B2)). For non-breaking spaces (character 160, common in web-pasted data), use SUBSTITUTE to replace them before TRIM.
  • Can I use EXACT to do a case-sensitive count?+
    Yes — use SUMPRODUCT with EXACT. COUNTIF is not case-sensitive and cannot be made so directly. The workaround is: =SUMPRODUCT(--(EXACT("APPLE", A2:A100))). The double negative (--) converts the TRUE/FALSE array from EXACT into 1s and 0s, which SUMPRODUCT then sums. Replace "APPLE" with a cell reference for a dynamic version: =SUMPRODUCT(--(EXACT(G1, A2:A100))). For a case-sensitive conditional sum, multiply by the value range: =SUMPRODUCT(--(EXACT(G1, A2:A100)) * B2:B100).
  • What is the difference between EXACT and the equals operator?+
    The equals operator (=) compares values without regard to case — "Apple" = "APPLE" returns TRUE. EXACT compares values including case — EXACT("Apple", "APPLE") returns FALSE. Additionally, the equals operator coerces data types, so the number 100 equals the text "100". EXACT does not coerce types — EXACT(100, "100") returns FALSE. Use = when case and type coercion do not matter (which is most of the time). Use EXACT when both strings must match precisely in every character, including upper and lower case.