FindNext Method

Applies To

Range Object.

Description

Continues a search started with the Find method. Finds the next cell matching the same conditions and returns a Range object that represents that cell. Does not affect the selection or active cell.

Syntax

object.FindNext(after)

object

Required. The range to search.

after

Optional. The first cell after which you want to search. This corresponds to the position of the active cell when a search is done from the user interface. If omitted, the top left cell of the range is used as the starting point for the search. Remember that the search begins after this cell; the specified cell is not searched until the method wraps back around to this cell.

Remarks

When the search reaches the end of the specified search range, it wraps around to the beginning of the range. To stop a search when this wraparound occurs, save the address of the first found cell, and then test each successive found-cell address against this saved address.

See Also

Find Method, FindPrevious Method, Replace Method.

Example

This example changes all occurrences of the word Phoenix in column A on Sheet1 to the word Flagstaff.


Set foundCell = Worksheets("Sheet1").Columns("A").Find("Phoenix")
Do While Not (foundCell Is Nothing)
    foundCell.Value = "Flagstaff"
    Set foundCell = Worksheets("Sheet1").Columns("A").FindNext
Loop