Compares two text strings and returns TRUE if they are exactly the same, FALSE otherwise. Case-sensitive comparison. Essential for data validation, text matching, and exact comparisons in Excel.
Master the fundamentals of Excel EXACT function
The EXACT function performs a case-sensitive comparison of two text strings, returning TRUE only if they are completely identical character by character. It's essential for data validation, password verification, case-sensitive text matching, and ensuring exact text equality in Excel.
Distinguishes between uppercase and lowercase
Returns TRUE only for identical strings
Considers all characters including spaces
Returns TRUE or FALSE
Function-specific parameters
Function-specific return type
Validate exact text matches
Check exact password matches
Compare text with case sensitivity
Use with IF for conditional actions
Exact matching required
Returns numeric position
Handles missing text gracefully
=EXACT(text1, text2)First text string to compare
Second text string to compare
TRUE if texts are identical, FALSE otherwise
Description: Compares two text strings and returns TRUE if they are exactly the same (case-sensitive)
Compare two text strings exactly
Returns FALSE because EXACT is case-sensitive - 'Excel' ≠ 'excel'
Simple VBA implementation of EXACT function
' Basic EXACT in VBA
Range("C1").Value = Application.WorksheetFunction.Exact(Range("A1").Value, Range("B1").Value)
' Using VBA Exact function
Dim text1 As String
Dim text2 As String
text1 = "Excel"
text2 = "excel"
Dim result As Boolean
result = Application.WorksheetFunction.Exact(text1, text2)
Debug.Print result ' Output: False
' Compare multiple cells
Sub CompareCells()
Dim cell As Range
For Each cell In Range("A1:A10")
Dim compareCell As Range
Set compareCell = cell.Offset(0, 1)
cell.Offset(0, 2).Value = Application.WorksheetFunction.Exact(cell.Value, compareCell.Value)
Next cell
End Sub
' Validate password match
Function ValidatePassword(inputPassword As String, correctPassword As String) As Boolean
ValidatePassword = Application.WorksheetFunction.Exact(inputPassword, correctPassword)
End FunctionComprehensive comparison with validation
' Compare with case handling options
Function CompareTextExact(text1 As String, text2 As String, Optional caseSensitive As Boolean = True) As Boolean
If caseSensitive Then
CompareTextExact = Application.WorksheetFunction.Exact(text1, text2)
Else
CompareTextExact = (UCase(text1) = UCase(text2))
End If
End Function
' Find exact matches in range
Function FindExactMatches(searchText As String, searchRange As Range) As Collection
Dim matches As New Collection
Dim cell As Range
For Each cell In searchRange
If Application.WorksheetFunction.Exact(cell.Value, searchText) Then
matches.Add cell.Address
End If
Next cell
Set FindExactMatches = matches
End Function
' Validate data entry
Sub ValidateDataEntry()
Dim inputCell As Range
Set inputCell = Range("B1")
Dim validValue As String
validValue = "Approved"
If Application.WorksheetFunction.Exact(inputCell.Value, validValue) Then
inputCell.Interior.Color = RGB(0, 255, 0) ' Green
Else
inputCell.Interior.Color = RGB(255, 0, 0) ' Red
End If
End SubValidate exact text matches in forms
Check exact password matches
Find exact case-sensitive matches
Use with IF for conditional actions
EXACT returns FALSE for seemingly identical strings
=EXACT(TRIM(A1), TRIM(B1))Solution: Check for: 1) Case differences (Excel vs excel), 2) Leading/trailing spaces, 3) Hidden characters. Use TRIM and compare lengths: =EXACT(TRIM(A1), TRIM(B1))
EXACT compares numbers as text, so 123 and "123" may not match
=EXACT(VALUE(A1), VALUE(B1))Solution: Convert both to same type: =EXACT(TEXT(A1, "0"), TEXT(B1, "0")) or =EXACT(VALUE(A1), VALUE(B1))
EXACT with empty cells may return unexpected results
=IF(OR(A1="", B1=""), "", EXACT(A1, B1))Solution: Handle empty cells: =IF(OR(A1="", B1=""), "", EXACT(A1, B1))
When case-insensitive comparison is needed, EXACT is not appropriate
=UPPER(A1)=UPPER(B1)Solution: Use comparison operator = with UPPER/LOWER: =UPPER(A1)=UPPER(B1)