Manually reconciling inconsistent text strings in Excel is a notoriously tedious and error-prone struggle for data analysts. While standard funding sources typically prioritize enterprise-level master data management software, departments often lack the budget for these platforms. Fortunately, leveraging Excel for fuzzy matching grants teams immediate analytical capability without additional software costs. The critical stipulation is that native Excel formulas like VLOOKUP only handle exact matches, necessitating the Microsoft Fuzzy Lookup Add-In for true similarity scoring. Below, we explore how to install this tool, build comparison formulas, and interpret similarity thresholds to streamline your data cleansing workflow.
Data cleaning and preparation are some of the most common challenges in Excel. One of the most frustrating hurdles is dealing with inconsistent text data. Whether you are merging customer lists, reconciling supplier invoices, or comparing product catalogs, you will inevitably encounter variations like "Apple Inc." versus "Apple," or "John Smith" versus "Jon Smith."
Standard lookup functions like VLOOKUP, XLOOKUP, or INDEX/MATCH are binary: they require an exact match (or an alphabetical approximation that rarely works for messy text). To solve this, you need fuzzy text matching-the ability to compare two strings and determine how similar they are on a scale from 0% to 100%.
This comprehensive guide explores four powerful ways to perform fuzzy text matching in Excel, ranging from native formulas and Power Query to advanced VBA macros and official add-ins.
If you cannot use VBA or Power Query due to organizational security policies, you can use a creative native formula to calculate a basic similarity score. This formula counts how many characters from the first string exist inside the second string, giving you a rough percentage of overlap.
Assuming your first string is in cell A2 and the second string is in cell B2, enter the following array formula (press Ctrl + Shift + Enter in older Excel versions, or just Enter in Excel 365):
=SUMPRODUCT(--(ISNUMBER(SEARCH(MID(A2, ROW(INDIRECT("1:" & LEN(A2))), 1), B2)))) / LEN(A2)
MID(A2, ROW(INDIRECT("1:" & LEN(A2))), 1): This dissects the string in cell A2 into an array of individual characters.SEARCH(..., B2): It searches for each of those individual characters inside cell B2. If a character is found, it returns its position (a number); if not, it returns a #VALUE! error.ISNUMBER(...): This converts the numbers to TRUE and the errors to FALSE.--(...): The double unary operator (double minus) converts TRUE/FALSE values into 1s and 0s.SUMPRODUCT(...): This sums all the 1s, which represents the total number of characters from A2 found in B2./ LEN(A2): Finally, dividing by the total length of A2 converts the count into a percentage score.Limitation: This method does not account for character order. For example, "cat" and "act" would return a 100% match because they share the exact same characters, even though they are different words.
For large datasets, the built-in Fuzzy Match engine in Power Query (available in Excel 2016 and newer) is the most professional and scalable approach. It uses the Jaccard similarity index behind the scenes to compare sets of characters.
The gold standard for programmatic fuzzy matching is the Levenshtein Distance algorithm. This algorithm counts the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into another.
By implementing this in VBA, you can create a custom Excel function called =FuzzyMatchPercent(string1, string2).
To add this code, press Alt + F11 to open the VBA Editor, click Insert > Module, and paste the following code:
Function LevenshteinDistance(ByVal s As String, ByVal t As String) As Long
Dim i As Long, j As Long, cost As Long
Dim lenS As Long, lenT As Long
Dim arr() As Long
s = LCase(Trim(s))
t = LCase(Trim(t))
lenS = Len(s)
lenT = Len(t)
If lenS = 0 Then LevenshteinDistance = lenT: Exit Function
If lenT = 0 Then LevenshteinDistance = lenS: Exit Function
ReDim arr(0 To lenS, 0 To lenT)
For i = 0 To lenS: arr(i, 0) = i: Next i
For j = 0 To lenT: arr(0, j) = j: Next j
For i = 1 To lenS
For j = 1 To lenT
If Mid(s, i, 1) = Mid(t, j, 1) Then
cost = 0
Else
cost = 1
End If
arr(i, j) = Application.Min(arr(i - 1, j) + 1, _
arr(i, j - 1) + 1, _
arr(i - 1, j - 1) + cost)
Next j
Next i
LevenshteinDistance = arr(lenS, lenT)
End Function
Function FuzzyMatchPercent(ByVal string1 As String, ByVal string2 As String) As Double
Dim maxLen As Long
Dim distance As Long
string1 = Trim(string1)
string2 = Trim(string2)
If string1 = "" Or string2 = "" Then
FuzzyMatchPercent = 0
Exit Function
End If
maxLen = Application.Max(Len(string1), Len(string2))
distance = LevenshteinDistance(string1, string2)
FuzzyMatchPercent = 1 - (distance / maxLen)
End Function
Once the code is saved, return to your Excel worksheet. You can now use your custom function just like any standard Excel formula:
=FuzzyMatchPercent(A2, B2)
Format the output cell as a Percentage. If A2 contains "Microsoft Corp" and B2 contains "Microsoft Corporation", the formula will return a highly accurate similarity ratio (approximately 71%).
For legacy Excel users or those looking for a dedicated out-of-the-box analytical tool, Microsoft provides a free Fuzzy Lookup Add-In.
Ctrl + T).No mathematical algorithm is perfectly psychic. To get the best results, always preprocess your text before running any fuzzy match formula or tool:
| Data Preparation Action | Excel Formula / Tool | Why it Helps |
|---|---|---|
| Remove leading & trailing spaces | =TRIM(text) |
Spaces count as characters; removing them immediately drops the distance score. |
| Force uniform casing | =LOWER(text) |
Ensures case sensitivity doesn't skew similarity measurements. |
| Strip non-printable characters | =CLEAN(text) |
Prevents hidden line breaks and web-formatting garbage from ruining matches. |
| Standardize common terms | Find & Replace (Ctrl + H) |
Replace variations like "Street" with "St." or "Incorporated" with "Inc." before matching. |
.xlsm formats) or external add-ins.
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.