Excel Formulas for Fuzzy Text Search and Matching in Datasets

📅 Jan 19, 2026 📝 Sarah Miller

Manually reconciling inconsistent text data in Excel is a tedious, error-prone challenge for busy analysts. While standard lookup functions like VLOOKUP or XLOOKUP are highly reliable for pristine datasets, they fail when faced with minor typos, abbreviations, or formatting variances. Implementing fuzzy search logic grants users the ability to automate data cleansing and merging without exhaustive manual prep. However, as a stipulation, true fuzzy matching in Excel requires leveraging the Microsoft Fuzzy Lookup Add-in or complex wildcard formulas, both of which demand careful threshold calibration. For example, aligning "Microsoft Corp" with "Microsoft Inc" requires defining specific similarity indexes. Below, we outline the exact formulas and tools needed to deploy robust fuzzy matching in your spreadsheets.

Excel Formulas for Fuzzy Text Search and Matching in Datasets

Data cleaning is one of the most time-consuming aspects of data analysis. Often, you are tasked with combining two datasets that share a common key, such as company names, customer names, or product codes. However, due to manual data entry errors, typos, abbreviations, or different formatting standards, an exact match is impossible. For instance, trying to match "Apple Inc." with "Apple" or "Apple Incorporated" using standard Excel lookup formulas like VLOOKUP, XLOOKUP, or INDEX/MATCH will result in frustrating #N/A errors.

This is where fuzzy text searching comes in. Fuzzy matching allows you to identify strings that are similar but not identical. While Excel does not have a single native "FUZZYLOOKUP" function, there are several powerful methods to perform fuzzy text searches using standard formulas, Power Query, the official Fuzzy Lookup Add-In, and VBA. In this comprehensive guide, we will explore these methods from the simplest formula-based partial matches to advanced algorithmic solutions.

Method 1: Using Wildcards in Native Excel Formulas

Before diving into complex algorithms, the simplest form of fuzzy searching in Excel is wildcard matching. Excel supports two main wildcards:

  • * (Asterisk): Represents any number of characters.
  • ? (Question Mark): Represents a single character.

The XLOOKUP Wildcard Formula

In modern Excel (Excel 365 and Excel 2021), XLOOKUP features built-in support for wildcard matching. If you want to find a partial match where your search term might be wrapped in other text, you can concatenate asterisks to your lookup value.

=XLOOKUP("*" & A2 & "*", B:B, C:C, "No Match", 2)

How it works:

  • "*" & A2 & "*": This wraps the value in cell A2 with wildcards, meaning Excel will look for any cell in column B that contains the text in A2.
  • 2 (Match Mode argument): This tells XLOOKUP to enable wildcard character matching.

The Classic INDEX-MATCH Partial Match Formula

If you are using an older version of Excel, you can achieve the same result using INDEX and MATCH:

=INDEX(C:C, MATCH("*" & A2 & "*", B:B, 0))

While wildcards are incredibly fast and easy to implement, they only solve the problem of containment (e.g., finding "Apple" within "Apple Inc."). They will fail if there are typos, such as matching "Aple" with "Apple".

Method 2: Advanced Formula-Based Array Search

To perform a more robust search where you want to find which string in a dataset contains the most character overlaps, you can construct an array formula using SEARCH, ISNUMBER, and FILTER or INDEX.

Imagine you have a list of correct product names in Column E, and a messy search term in cell A2. You want to find which correct name contains your search term, or vice-versa.

=INDEX(E$2:E$100, MATCH(TRUE, ISNUMBER(SEARCH(E$2:E$100, A2)), 0))

Note: If you are not using Excel 365, you must press Ctrl + Shift + Enter to enter this as an array formula.

How it works:

  1. SEARCH(E$2:E$100, A2): This searches for every term in the correct list (Column E) inside the messy string (A2). It returns an array of numbers (the start position of the match) or #VALUE! errors.
  2. ISNUMBER(...): Converts the numbers to TRUE and the errors to FALSE.
  3. MATCH(TRUE, ..., 0): Finds the position of the first TRUE in the array.
  4. INDEX(...): Retrieves the actual matched name from Column E.

Method 3: The Modern Way – Power Query Fuzzy Merge

If you are working with large datasets, writing formulas for fuzzy matching can grind your computer to a halt. The most robust, scalable, and modern way to perform fuzzy searches in Excel is by using Power Query's Fuzzy Merge feature, which is built directly into Excel 2016 and later.

Step-by-Step Guide to Fuzzy Merge:

  1. Select your first table (the one with the messy data), go to the Data tab, and click From Table/Range. This loads your data into the Power Query Editor. Close and load it as a connection only.
  2. Do the same for your second table (the master list/clean data).
  3. Go to Data > Get Data > Combine Queries > Merge.
  4. In the Merge window, select your messy table as the top table and your clean master table as the bottom table.
  5. Click on the columns you want to match between the two tables.
  6. Check the box that says "Use fuzzy matching to perform the merge".
  7. Expand the Fuzzy matching options to fine-tune your search:
    • Similarity threshold: This value ranges from 0.00 to 1.00. A value of 1.00 requires an exact match. A value of 0.00 will match anything. The default is 0.80, which is usually the sweet spot for spelling mistakes.
    • Ignore case: Keep this checked so "apple" matches "Apple".
    • Match by combining parts: This allows words to be split up (e.g., matching "JohnSmith" with "John Smith").
  8. Click OK, expand the matched column in Power Query, and then click Close & Load to bring your beautifully matched data back into an Excel spreadsheet.

Method 4: VBA User Defined Function (UDF) for Levenshtein Distance

For those who want to run fuzzy searches directly inside cell formulas without loading data into Power Query, you can implement the Levenshtein Distance algorithm using a custom VBA macro. The Levenshtein Distance 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 i As Long, j As Long
    Dim len1 As Long, len2 As Long
    Dim matrix() 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 VBA Function

Once you have added this code, you can use the =Levenshtein() function just like a regular Excel formula. It will return an integer representing the edit distance. A score of 0 means an exact match.

For example, if cell A2 contains "Microsoft" and B2 contains "Micro-soft":

=Levenshtein(A2, B2)

This formula will return 1, because only one modification (removing the hyphen) is needed to make the strings identical.

To use this to find the closest match in a table, you can pair it with a helper column or array scan to find the item with the lowest Levenshtein score.

Method 5: Microsoft's Legacy Fuzzy Lookup Add-In

If you are using an older version of Excel that does not support Power Query or if you prefer a dedicated user interface, Microsoft offers a free, downloadable COM add-in called the Fuzzy Lookup Add-In for Excel. While older, it remains highly effective for matching databases.

Once downloaded and installed from Microsoft's official website, a new "Fuzzy Lookup" tab will appear on your Excel ribbon. It functions similarly to Power Query's fuzzy merge, allowing you to select left and right tables, configure similarity thresholds, and output a detailed mapping table complete with match confidence scores.

Summary of Methods: Which One Should You Choose?

Method Best For Pros Cons
Wildcard Formulas (XLOOKUP) Simple sub-string searches No setup required; lightning fast Cannot handle typos or structural differences
Power Query Fuzzy Merge Large datasets and repeatable data pipelines No coding required; highly customizable; scalable Requires converting datasets into Excel Tables first
VBA Levenshtein Distance Dynamic, on-the-fly cell calculation Highly accurate; works directly in spreadsheet cells Requires macro-enabled workbook (.xlsm); slow on huge datasets
Fuzzy Lookup Add-In Legacy Excel versions or rapid ad-hoc matching Dedicated UI; provides confidence ratings Requires a separate installation; less integrated than Power Query

Conclusion

Fuzzy searching in Excel no longer requires manual, line-by-line validation of messy datasets. For quick containment checks, the wildcard-driven XLOOKUP is your best friend. When you are cleaning up entire business reports or merging customer databases, setting up a Power Query Fuzzy Merge is by far the most efficient and future-proof workflow. Choose the tool that best fits your dataset's complexity, and say goodbye to manual data cleansing!

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.