Excel VBA FindNext: How to Find the Next Match

VBA & macros · Updated November 3, 2026

Excel VBA FindNext: How to Find the Next Match

In Excel VBA, use Range.FindNext to move from one match to the next after starting a search with Range.Find. To find every match safely, keep calling FindNext until the search returns to the address of the first match; Excel’s search wraps around at the end of the range.

What FindNext does

FindNext is a method of Excel’s Range object. It searches for another occurrence using the search criteria and range from the preceding Find or FindNext operation. It does not accept a new search term or a new set of options. That is why a typical VBA search has two parts: call Find to set up the search, then call FindNext to continue it.

For example, if a worksheet has several cells containing “North,” Find locates the first match and FindNext advances to another one. You can use the returned Range to read a value, record the cell address, or take an action. The method is useful for repeated matches, but the wraparound behavior means a loop needs an explicit stopping condition.

How Find and FindNext work together

A Find call returns a Range for the first matching cell, or Nothing if there is no match. Its optional arguments specify what to search for and how: for example, whether to match the whole cell or part of its contents, whether to search values or formulas, and whether to distinguish uppercase and lowercase letters.

Excel remembers several Find settings between searches, including settings changed through the Find dialog. To make a macro predictable, specify the important arguments each time you call Find, rather than relying on a user’s previous search. FindNext then continues with those established criteria. Its After argument identifies the cell after which the next search begins; it must be a single cell in the search range.

The order matters. A range search proceeds from the cell after the specified starting cell and eventually wraps back to the beginning. If you need to process every match, save the first match’s address and stop when that address appears again. Without that check, a loop can search forever.

A reliable FindNext loop

This example searches A1:A100 on Sheet1 for cells whose value is exactly “North.” It prints each matching cell address in the VBA editor’s Immediate window. In the Visual Basic Editor, press Ctrl+G on Windows to show that window.

Sub ListNorthMatches()
    Dim searchRange As Range
    Dim foundCell As Range
    Dim firstAddress As String

    ' Search one continuous range on the named worksheet.
    Set searchRange = ThisWorkbook.Worksheets("Sheet1").Range("A1:A100")

    ' Start after the last cell so the first cell is considered first.
    Set foundCell = searchRange.Find( _
        What:="North", _
        After:=searchRange.Cells(searchRange.Cells.Count), _
        LookIn:=xlValues, _
        LookAt:=xlWhole, _
        SearchOrder:=xlByRows, _
        SearchDirection:=xlNext, _
        MatchCase:=False, _
        SearchFormat:=False)

    If Not foundCell Is Nothing Then
        firstAddress = foundCell.Address

        Do
            Debug.Print foundCell.Address
            Set foundCell = searchRange.FindNext(After:=foundCell)

            ' Stop if no match remains or the search has wrapped around.
            If foundCell Is Nothing Then Exit Do
        Loop While foundCell.Address <> firstAddress
    End If
End Sub

The first test prevents an error when no cell matches: a variable set to Nothing has no address to read. After the first match, the loop prints the current address, advances, and exits if it has returned to the starting address. Because the range is searched in row order, the starting cell is A1 in this example.

Before running a macro, save a copy of the workbook. Macro actions cannot be undone with Ctrl+Z, even when the macro only appears to make a small change. This sample prints addresses rather than editing cells, but the same precaution is sensible when adapting it.

Choosing the search options

The arguments passed to Find determine what counts as a match. They are often the difference between a correct result and a macro that seems to miss data.

  • What is the text, number, or other search value. Wildcards can be useful for text searches: * represents any number of characters and ? represents one character.
  • LookIn:=xlValues searches cell values, including the displayed results of formulas. Use LookIn:=xlFormulas when the formula contents themselves are what you want to find.
  • LookAt:=xlWhole requires the entire cell to match. LookAt:=xlPart also matches a search term within a longer cell entry.
  • SearchOrder:=xlByRows moves across rows; xlByColumns searches down columns before moving across.
  • SearchDirection:=xlNext searches forward through the range. xlPrevious searches in the reverse direction.
  • MatchCase:=True distinguishes uppercase and lowercase. With False, “North” and “north” can both match.
  • SearchFormat:=False avoids applying a format criterion left over from an earlier Find operation.

For a worksheet where A2 contains North Region, searching for North with LookAt:=xlWhole will not find that cell; LookAt:=xlPart will. If a formula in B2 displays the word North, xlValues searches the displayed result, while xlFormulas searches the formula stored in the cell. Pick the option that matches the data you mean to find.

Finding all matches and acting on them

The loop can do more than print addresses. Inside the loop, you might add each result to a collection, inspect another column on the same row, or count matches. For example, if column A contains product categories and column B contains quantities, a search of column A can use foundCell.Row to identify the corresponding quantity in column B. Check that the row and column references stay within the intended worksheet.

Be cautious about changing the cells being searched while the loop is running. Editing a match can make it stop matching, or a new value can introduce another match. That can make results harder to reason about. If the task is to replace all occurrences, Excel’s built-in Replace feature or a carefully designed loop may be more appropriate; test on a copy first. For a stable search, collect the matching addresses first and make edits in a separate pass.

Keep the search range as narrow as practical. Searching a known data column is usually clearer and faster than searching every cell in a worksheet. A single continuous range, such as A1:A100 or A:A, also makes the search boundaries easier to understand. If the data is in several separate blocks, search each block individually rather than assuming a multi-area range will behave like one continuous range.

Common FindNext problems

  • The macro stops with an object error: the initial Find returned Nothing. Check If Not foundCell Is Nothing Then before reading its address or calling FindNext.
  • The loop never ends: the code has no wraparound check. Save the first result’s address and stop when the search reaches it again.
  • It finds partial text unexpectedly: set LookAt explicitly to xlWhole or xlPart.
  • It misses a value that appears on screen: check whether the search should use xlValues or xlFormulas, and confirm the search range includes the cell.
  • Results differ between runs: specify the Find arguments instead of depending on remembered dialog settings. Also check for a leftover format search criterion.
  • It searches in an unexpected order: set SearchOrder and SearchDirection explicitly and choose an intentional After cell.

Another common mistake is calling FindNext without first getting a valid result from Find. Start each independent search with Find; do not assume that a prior search’s settings or current position are still suitable for a different task.

FindNext compared with other ways to search

FindNext is designed to continue a cell search. Use Find when you need to start a search or change its criteria. Use FindPrevious when you want to continue in the reverse direction. The Find dialog is convenient for a person searching interactively, but a macro needs explicit logic for processing matches and stopping at the right time.

For a simple check that one value exists, a loop may be unnecessary: call Find once and test whether the result is Nothing. For a larger data task, Excel features such as filters may be easier to inspect and maintain. FindNext is most helpful when VBA needs to visit individual matching cells and perform a specific action for each one.

Excel version and platform notes

Range.Find and Range.FindNext are long-standing Excel VBA methods, not functions limited to a particular Microsoft 365 formula release. The example is written for desktop Excel on Windows. Excel for Mac also supports VBA, though the Visual Basic Editor’s menus and keyboard shortcuts can differ; the search logic and method names are the same. Excel for the web does not run VBA macros, so open the workbook in the desktop app to use this code.

To run the procedure, save the workbook in a macro-enabled format such as .xlsm, open the Visual Basic Editor, insert the code in a standard module, and run the macro with the workbook containing Sheet1 active or available as ThisWorkbook. Macro security settings may require you to enable macros for a trusted file. Do not enable macros in an unfamiliar workbook simply to test its contents.

Frequently Asked Questions

What is the syntax for VBA FindNext?
Use someRange.FindNext(After:=someCell) after a successful Find. The range should be the range used for the search, and someCell should be one cell within it.

Does FindNext search the whole worksheet?
It continues the search associated with the range on which you called Find. If you want to search the whole worksheet, set the initial search range to the worksheet’s cells; for many tasks, a smaller used data range is more practical.

Why does FindNext return to the first match?
Excel wraps to the beginning after reaching the end of the search range. This is expected behavior. Compare each result’s address with the saved first address to recognize when a complete cycle is done.

Can FindNext find formula results?
Yes. Start with Find and set LookIn:=xlValues to search values, including results displayed by formulas. Use xlFormulas when you need to search the formulas themselves.

Can I use FindNext without Find?
For a new search, call Find first to establish the search criteria and get an initial result. If that call returns Nothing, there is no match to continue from.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.