Syntax

expression.FindPrevious(After)

expression A variable that represents a Range object.

Parameters

Name Required/Optional Data Type Description
After Optional Variant The cell before which you want to search. This corresponds to the position of the active cell when a search is done from the user interface. Note that After must be a single cell in the range. Remember that the search begins before this cell; the specified cell isn't searched until the method wraps back around to this cell. If this argument isn't specified, the search starts before the upper- left cell in the range.

Return Value
Range

Remarks

When the search reaches the beginning of the specified search range, it wraps around to the end 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.

Example

This example shows how the FindPrevious method is used with the Find and methods. Before running this example, make sure that Sheet1 contains at least two occurrences of the word "Phoenix" in column B.

Visual Basic for Applications
Sub FindTest() Dim fc As Range Set fc = Worksheets("Sheet1").Columns("B").Find(what:="Phoenix") MsgBox "The first occurrence is in cell " & fc.Address Set fc = Worksheets("Sheet1").Columns("B").FindNext(after:=fc) MsgBox "The next occurrence is in cell " & fc.Address Set fc = Worksheets("Sheet1").Columns("B").FindPrevious(after:=fc) MsgBox "The previous occurrence is in cell " & fc.Address End Sub
find Find previous Find Previous Method FindPrevious FindPrevious method findprevious method Look for the previous matching formula? Return the previous matching value in a table. Search for previous matching keyword in notes on my report?

See also: