Manually reconciling inconsistent text data in Excel is a notoriously tedious struggle for database analysts. Often, teams attempt to align internal records with contact lists from standard funding sources, only to find that traditional exact-match formulas fail due to minor typos. Fortunately, deploying a fuzzy match formula grants you the ability to automate this reconciliation with high precision. To ensure accuracy, the key stipulation is establishing a strict similarity threshold to prevent false positives. For example, successfully mapping "Govt Grant Corp" to "Government Grant Corporation" demonstrates this method's power. Below, we outline the exact formula architecture and configuration steps to implement this solution.
Data normalization is one of the most common challenges database administrators, financial analysts, and market researchers face in Excel. Standard lookup functions like VLOOKUP, XLOOKUP, and INDEX/MATCH are exceptional at finding exact matches. However, they fail instantly when faced with minor typos, variations in spacing, missing words, or different suffix styles (e.g., "Apple Inc." vs. "Apple Incorporated").
To solve this, we must turn to fuzzy text matching. Fuzzy matching calculates the degree of similarity between two text strings and returns a score, typically between 0 (completely different) and 1 (an exact match). By setting a similarity threshold (such as 0.80 or 80%), you can instruct Excel to match records that are "close enough."
In this guide, we will explore the three most effective ways to perform fuzzy matching in Excel based on a similarity threshold: using Power Query, writing a custom VBA User-Defined Function (UDF), and leveraging modern Excel 365 formulas.
If you are using Excel 2019, Excel 2021, or Microsoft 365, Power Query is the most robust and user-friendly tool for fuzzy matching. It has a built-in fuzzy matching engine that allows you to configure similarity thresholds without writing complex code.
Ctrl + T). Name them SourceData and LookupTable.SourceData table in the top dropdown and your LookupTable in the bottom dropdown.If your project demands a dynamic, formula-based layout that automatically updates when sheet values change-and you cannot use Power Query-a custom VBA function is the best approach. We will implement the Levenshtein Distance algorithm, which counts the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into another.
By normalizing this distance against the length of the longer string, we get a similarity percentage between 0 and 1.
Press Alt + F11 to open the VBA Editor. Click Insert > Module, and paste the following code:
Function LevenshteinSimilarity(ByVal string1 As String, ByVal string2 As String) As Double
Dim len1 As Long, len2 As Long
Dim matrix() As Long
Dim i As Long, j As Long
Dim cost As Long
Dim maxLen As Long
' Clean and normalize text to lowercase
string1 = LTrim(RTrim(LCase(string1)))
string2 = LTrim(RTrim(LCase(string2)))
len1 = Len(string1)
len2 = Len(string2)
If len1 = 0 Then
If len2 = 0 Then LevenshteinSimilarity = 1.0 Else LevenshteinSimilarity = 0.0
Exit Function
End If
If len2 = 0 Then
LevenshteinSimilarity = 0.0
Exit Function
End If
' Determine max length for similarity scaling
If len1 > len2 Then maxLen = len1 Else maxLen = len2
ReDim matrix(0 To len1, 0 To len2)
For i = 0 To len1: matrix(i, 0) = i: Next i
For j = 0 To len2: matrix(0, j) = j: Next j
For i = 1 To len1
For j = 1 To len2
If Mid(string1, i, 1) = Mid(string2, j, 1) Then
cost = 0
Else
cost = 1
End If
matrix(i, j) = Application.WorksheetFunction.Min( _
matrix(i - 1, j) + 1, _
matrix(i, j - 1) + 1, _
matrix(i - 1, j - 1) + cost)
Next j
Next i
' Calculate similarity percentage
LevenshteinSimilarity = 1 - (matrix(len1, len2) / maxLen)
End Function
Once the VBA code is in place, you can use the function =LevenshteinSimilarity(text1, text2) directly inside your cells.
To perform a lookup across an entire table and pull the match only if it meets a similarity threshold of 80% (0.80), combine this custom function with XLOOKUP or INDEX/MATCH. For example, if your search term is in cell A2 and your target lookup column is $E$2:$E$100, enter the following array formula (press Ctrl + Shift + Enter in older Excel versions):
=INDEX($E$2:$G$100, MATCH(MAX(MAP($E$2:$E$100, LAMBDA(val, LevenshteinSimilarity(A2, val)))), MAP($E$2:$E$100, LAMBDA(val, LevenshteinSimilarity(A2, val))), 0), 2)
To make this cleaner, you can separate the similarity scores into a helper column. Put =LevenshteinSimilarity(A2, E2) in a column next to your lookup table, filter/evaluate matches that score >= 0.80, and retrieve corresponding values.
For Microsoft 365 users who want a pure, formulas-only approach without macro workbooks (.xlsm), we can create a token-overlap similarity formula. This method splits both strings into individual words (tokens) and calculates how many words from the search string exist in the target string relative to the total word count.
Assuming cell A2 contains "Microsoft Corporation" and cell B2 contains "Microsoft Corp", the following dynamic formula calculates their token similarity score:
=LET(
wordsA, TEXTSPLIT(LOWER(A2), " "),
wordsB, TEXTSPLIT(LOWER(B2), " "),
commonWords, REDUCE(0, wordsA, LAMBDA(acc,val, acc + IF(ISNUMBER(XMATCH(val, wordsB)), 1, 0))),
maxWords, MAX(COUNTA(wordsA), COUNTA(wordsB)),
commonWords / maxWords
)
LET: Assigns local variables to keep the formula readable and performant.TEXTSPLIT: Splits the text values into arrays of words based on space characters (" "). We wrap them in LOWER to ignore case sensitivity.REDUCE and LAMBDA: Iterates through each word in the first string (wordsA) and counts how many times those words match anywhere in the second string (wordsB).maxWords: Finds the maximum total word count between the two fields to serve as our denominator.You can wrap this logic in an IF statement to evaluate your threshold. For example, if your threshold is 0.70, you can output "Match" or "Check Manually":
=IF([Similarity Formula] >= 0.70, "Valid Match", "No Match")
Your choice depends on the structure of your workbook and how comfortable you are with developer tools:
| Method | Pros | Cons | Best Used For |
|---|---|---|---|
| Power Query Fuzzy Merge | Native GUI, extremely fast, no programming required, handles large datasets efficiently. | Requires manual data refresh; not a real-time worksheet cell formula. | Comparing large, static transactional datasets, customer contact databases, and mailing list cleaning. |
| VBA Levenshtein UDF | Functions like a native Excel formula, recalculates instantly, highly customizable character-by-character analysis. | Requires saving files as Macro-Enabled (.xlsm), which can be flagged by IT security policies. Slow on massive worksheets. |
Interactions on interactive dashboards, small-scale lookups, and files where macros are already allowed. |
| M365 Token-Overlap | No macros/VBA, clean workbooks, works in Excel Online, great for multi-word business names. | Limited to Microsoft 365. Fails to catch single-character spelling mistakes (like "Appel" vs "Apple") because it evaluates whole words. | Quick, modern checks on clean systems matching multi-word product names, brands, or descriptions. |
Fuzzy matching with a similarity threshold transforms how we handle dirty and unstructured data in Excel. For regular database cleaning pipelines, Power Query's Fuzzy Merge is unmatched in convenience and optimization. For automated, on-the-sheet lookups, using a VBA Levenshtein Distance function or a modern 365 token-split formula provides the flexibility needed to handle complex datasets on the fly.
Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.