Excel Formulas for Fuzzy Text Matching Against a Master Database

📅 Jun 26, 2026 📝 Sarah Miller

Matching inconsistent text entries to a master database is a notorious hurdle for data analysts, leading to tedious manual reconciliation. While standard funding sources often demand strict data compliance before allocating operational budgets, manual auditing drains valuable resources. Implementing an Excel fuzzy matching formula grants teams the ability to automate approximate string comparisons instantly. A critical stipulation, however, is that users must configure specific similarity thresholds to prevent false positives. Utilizing these formulas for matching client lists-a standard practice in banking audits-proves their real-world reliability. Below, we outline the exact steps and formulas required to establish this fuzzy matching system in your workbook.

Excel Formulas for Fuzzy Text Matching Against a Master Database

Data normalization is one of the most common yet frustrating challenges Excel users face. You have a transaction list, a CRM export, or a mailing list with names like "Apple, Inc.", "Apple", "Aplle Inc", or "Microsoft Corp.", and you need to match these messy records against a clean, standardized master database.

A standard exact-match VLOOKUP, INDEX/MATCH, or XLOOKUP will fail immediately when confronted with these minor variations. To solve this, you need fuzzy text matching-the ability to identify and match strings that are similar but not identical. While Excel does not have a native, single-click FUZZYLOOKUP() formula, you can achieve highly accurate results using a variety of methods: native wildcard formulas, Power Query, the official Fuzzy Lookup Add-in, and VBA-based algorithms like Levenshtein Distance.

Method 1: Native Wildcard Formulas for Substring Matches

If your variations are simply cases of one string being a subset of another (e.g., matching "Apple" against "Apple Inc."), you can use wildcards within standard Excel lookup functions. The asterisk (*) acts as a placeholder for any number of characters.

Using XLOOKUP with Wildcards

Excel's modern XLOOKUP function supports wildcard matching natively when its fifth argument (match_mode) is set to 2. Here is how you can write a formula to search for a partial match from your lookup cell (A2) within a master database column (MasterTable[Company Name]):

=XLOOKUP("*" & A2 & "*", MasterTable[Company Name], MasterTable[ID], "No Match", 2)

How it works: By concatenating asterisks before and after cell A2 ("*" & A2 & "*"), you instruct Excel to find any record in the master list that contains the text in A2. The 2 at the end tells XLOOKUP to perform a wildcard match.

Using INDEX, MATCH, and SEARCH (The Classic Alternative)

If you are using an older version of Excel that does not support XLOOKUP, you can achieve a similar partial-match outcome using an array formula combining INDEX, MATCH, and SEARCH:

=INDEX(MasterTable[ID], MATCH(TRUE, ISNUMBER(SEARCH(A2, MasterTable[Company Name])), 0))

How it works: The SEARCH function is case-insensitive and looks for the string in A2 within the entire MasterTable column. If it finds it, it returns a number (the start position); if not, it returns a #VALUE! error. ISNUMBER converts these to TRUE or FALSE, and MATCH finds the first TRUE value to return the corresponding ID via INDEX.

Limitations: Wildcard and substring methods are limited. They cannot resolve spelling mistakes (e.g., matching "Aplle" to "Apple") or transpositions.

Method 2: Power Query Fuzzy Merge (The Modern, No-Code Solution)

For large-scale data cleaning, Power Query is the most robust and scalable tool built directly into Excel (Excel 2016 and later). It features a native, highly configurable fuzzy matching engine that does not require writing complex formulas.

Step-by-Step Power Query Fuzzy Matching:

  1. Load Your Tables: Select your dirty data table, go to the Data tab, and click From Sheet / Table/Range. Do the same for your Master Database table. This opens the Power Query Editor.
  2. Merge Queries: Close and load both queries as "Connection Only." Then, go to Data > Get Data > Combine Queries > Merge.
  3. Configure Fuzzy Matching:
    • Select your dirty table as the top table and your Master table as the bottom table.
    • Click on the columns in both tables that contain the text you want to match.
    • Check the box that says "Use fuzzy matching to perform the merge".
  4. Fine-Tune Fuzzy Options: Expand the Fuzzy matching options drop-down:
    • Similarity Threshold: A value between 0.00 and 1.00. 1.00 is an exact match. The default is 0.80. If you are getting too many false positives, raise it to 0.85 or 0.90. If you are missing matches, lower it to 0.70.
    • Ignore Case / Ignore Spaces: Keep these checked to normalize basic formatting differences.
    • Transformation Table: If you have common abbreviations (e.g., "Co." for "Company", "Corp" for "Corporation"), you can create a separate two-column table mapping these terms and select it here to dramatically improve match accuracy.
  5. Expand and Load: Click OK. In the merged column, click the expand icon to pull in the standardized name or ID from your Master Database. Select Close & Load to return the clean data to your Excel sheet.

Method 3: VBA Levenshtein Distance (Creating a Custom Fuzzy Formula)

If you need a dynamic, formula-driven approach that updates instantly as you type and can handle spelling errors, you can create a custom User Defined Function (UDF) using VBA. We will implement the Levenshtein Distance algorithm, which calculates the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into another.

The VBA Code

Press ALT + F11 to open the VBA Editor. Click Insert > Module, and paste the following code:

Function Levenshtein(ByVal string1 As String, ByVal string2 As String) As Long
    Dim matrix() As Long
    Dim len1 As Long, len2 As Long
    Dim i As Long, j As Long
    Dim cost As Long
    
    string1 = LCase(Trim(string1))
    string2 = LCase(Trim(string2))
    
    len1 = Len(string1)
    len2 = Len(string2)
    
    ReDim matrix(len1, 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) = Minimum(matrix(i - 1, j) + 1, _
                                   matrix(i, j - 1) + 1, _
                                   matrix(i - 1, j - 1) + cost)
        Next j
    Next i
    
    Levenshtein = matrix(len1, len2)
End Function
Private Function Minimum(x As Long, y As Long, z As Long) As Long
    Dim min As Long
    min = x
    If y < min Then min = y
    If z < min Then min = z
    Minimum = min
End Function

How to Use the Custom Formula

Once the code is pasted, close the VBA window and return to your Excel worksheet. You can now use the =Levenshtein() function just like a regular Excel formula.

To find the closest match in your master database using this UDF, you can combine it with XLOOKUP or INDEX/MATCH. For example, if you want to find the entry in MasterTable[Company Name] that has the lowest edit distance to your dirty value in cell A2, use this array formula (entered with Ctrl+Shift+Enter in older Excel versions):

=INDEX(MasterTable[Company Name], MATCH(MIN(Levenshtein(A2, MasterTable[Company Name])), Levenshtein(A2, MasterTable[Company Name]), 0))

This formula calculates the Levenshtein distance between A2 and every item in your master list, finds the minimum distance (the closest match), and returns the corresponding clean name.

Best Practices for Data Pre-Processing

Fuzzy matching engines perform exponentially better if you clean your data before running matches. Standardizing data beforehand reduces the noise the algorithms have to parse through.

  • Remove Extra Spaces: Use the TRIM() function to eliminate leading, trailing, and double spaces.
  • Normalize Case: Force all strings to lowercase or uppercase using LOWER() or UPPER(). While Power Query and many VBA scripts handle this, starting with normalized casing prevents errors.
  • Strip Common Punctuation: Use SUBSTITUTE() to strip out periods, commas, hyphens, and slashes. For example, changing "Company, Inc." to "Company Inc" prevents punctuation from skewing similarity scores.
  • Establish a Cutoff Threshold: When using Power Query or VBA distances, never accept matches blindly. Always review rows where the similarity is below 85% or the Levenshtein distance is greater than 3 or 4 characters.

Summary: Which Method Should You Choose?

Method Best For Pros Cons
Wildcard Formulas Simple substring lookups (e.g., "Microsoft" to "Microsoft Corp") Fast, dynamic, no setup or VBA required. Cannot handle typos or transposed characters.
Power Query Fuzzy Merge Large datasets, complex cleaning, recurring data imports No coding, highly configurable, handle synonyms via transform tables. Requires manual query refresh; not dynamic.
VBA Levenshtein Dynamic calculations, interactive templates Real-time updating, works directly inside worksheet cells. Can slow down Excel on huge datasets (over 10,000 rows).

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.