Reconciling inconsistent client and entity names in Excel remains a tedious, error-prone obstacle for finance professionals. When auditing capital allocation, teams must routinely aggregate disparate data from standard funding sources like federal grants, venture portfolios, and private endowments. Deploying an advanced fuzzy matching formula grants organizations the power to automatically unify mismatched records while generating precise similarity scores. As a vital educational stipulation, however, users must calibrate strict threshold limits to avoid false positives. For example, distinguishing "Capital One" from "Capital 1" requires exact percentage-based tuning. Below, we detail the step-by-step methodology to build this robust aggregation formula.
Data normalization is one of the most common yet frustrating challenges in data analysis. When merging databases, managing CRM contact lists, or consolidating sales figures, you are bound to encounter variations of the same name. "Microsoft Corp," "Microsoft Corporation," "Microsoft," and "Micro soft" all represent the same entity, but to traditional Excel formulas like VLOOKUP, XLOOKUP, or SUMIFS, they are completely different strings.
To consolidate these records, we must use fuzzy matching. This technique calculates a similarity score between two text strings and groups them if they meet a specific threshold. While legacy versions of Excel required complex VBA or external add-ins, modern Excel offers native solutions like Power Query, alongside custom formula-based architectures to aggregate and analyze fuzzy-matched names seamlessly.
In this guide, we will explore the best methods to aggregate values from fuzzy-matched names, complete with step-by-step instructions, formulas, and VBA workflows.
The most robust, scalable, and native way to handle fuzzy matching and aggregation in Excel is through Power Query (available in Excel 2016 and later). Power Query features a built-in fuzzy matching engine based on the Jaccard index similarity algorithm.
Imagine you have a sales table containing names with typos and variations, and you want to aggregate the total sales for each unique client group.
| Customer Name (Raw) | Sales Amount |
|---|---|
| Acme Corp. | $1,200 |
| Acme Corporation | $850 |
| Akme Corp | $450 |
| Globex LLC | $3,000 |
| Globex Ltd. | $1,500 |
0.80 is generally the optimal balance for catching typos while avoiding false positives.If you need real-time calculations directly within your workbook cells without refreshing Power Query, you can use a custom VBA User-Defined Function (UDF) to calculate the Levenshtein Distance. This algorithm measures the minimum number of single-character edits required to change one word into another.
Press ALT + F11 to open the VBA Editor, insert a new module, and paste the following code:
Function LevenshteinSimilarity(ByVal string1 As String, ByVal string2 As String) As Double
Dim len1 As Integer, len2 As Integer
Dim matrix() As Integer
Dim i As Integer, j As Integer
Dim cost As Integer
string1 = LCase(Trim(string1))
string2 = LCase(Trim(string2))
len1 = Len(string1)
len2 = Len(string2)
If len1 = 0 Then
LevenshteinSimilarity = IIf(len2 = 0, 1, 0)
Exit Function
End If
If len2 = 0 Then
LevenshteinSimilarity = 0
Exit Function
End If
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.Min(matrix(i - 1, j) + 1, _
matrix(i, j - 1) + 1, _
matrix(i - 1, j - 1) + cost)
Next j
Next i
' Calculate percentage similarity
Dim maxLen As Integer
maxLen = IIf(len1 > len2, len1, len2)
LevenshteinSimilarity = 1 - (matrix(len1, len2) / maxLen)
End Function
Once the VBA module is saved, you can use =LevenshteinSimilarity(text1, text2) directly inside Excel cells to output a similarity score from 0 (completely different) to 1 (exact match).
To aggregate data based on this score, set up a helper column system:
A2 and your standard/master list starts in column E. Find the best match from your Master List using a dynamic array formula:
=INDEX(MasterList, MATCH(MAX(LevenshteinSimilarity(A2, MasterList)), LevenshteinSimilarity(A2, MasterList), 0))
SUMIFS formula to aggregate the values:
=SUMIFS(Sales_Amount, Helper_Column_Mapped_Names, "Acme Corp")
For users on older versions of Excel or those who prefer a dedicated wizard interface, Microsoft provides a free desktop add-in called the Fuzzy Lookup Add-In for Excel.
Ctrl + T).Regardless of the method you choose, matching text programmatically carries a risk of mismatches (false positives). To ensure your aggregated financials or reporting metrics remain precise, implement the following best practices:
TRIM function, and convert everything to lowercase to optimize matching speeds and accuracy.Using raw strings to build reports is a recipe for incomplete metrics. By leveraging either Power Query's Fuzzy Merge for scalable automated pipelines or a Levenshtein VBA function for cell-based dynamic calculations, you can easily group similar items, assign accurate similarity scores, and calculate precise aggregate values across your entire dataset.
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.