Find Method

The Find method searches for a target string within a range in a worksheet.

Syntax

object.Find( TargetStr, After, Scope, Method, MatchCase, DelSelFirst, FindAll, OrderByRows )

 

Parameter Type Description
TargetStr String required; search target string
After Variant required; a single cell, search starts after this cell
Scope wksFindScope optional; search a row, column, or the entire worksheet, default is wksFindScopeEntire
Method wksFindMethod optional; find the exact information, a phrase, all words or any words; the default is wksFindExact
MatchCase Boolean optional; true to match case, default is false
DelSelFirst Boolean optional; deselect cells before search; default is true - deselect the cells
FindAll Boolean optional; true to find all occurrences of the search string, false to find one occurrence; default is false
OrderByRows Boolean optional; Scope should be wksFindScopeEntire to use OrderByRows, True to finish searching a row before going to the next row, false to finish searching a column before going to the next column; default is false

Remarks

The Find method causes the worksheet window's active cell to move to the cell where the string was found. Use the ActiveCell property of the AutoWksWindow object to identify the cell containing the string.

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 (row,col) coordinates of the first found cell, and then test each successive found-cell's coordinates against the saved coordinates.

Example

This example shows how to find “a” in a worksheet cell.

 

Set After= Cells("A1")

Set Found = Range.Find("a",After,wksFindScopeEntire,wksFindExact,False,False,True,False)

Used by: WksCellFormat