Range.Find (Excel)

Finds specific information in a range.

This method returns Nothing if no match is found. The Find method does not affect the selection or the active cell. The settings for LookIn, LookAt, SearchOrder, and MatchByte are saved each time you use this method. If you do not specify values for these arguments the next time you call the method, the saved values are used. Setting these arguments changes the settings in the Find dialog box, and changing the settings in the Find dialog box changes the saved values that are used if you omit the arguments. To avoid problems, set these arguments explicitly each time you use this method. You can use the FindNext and FindPrevious methods to repeat the search. 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. To find cells that match more complicated patterns, use a For Each...Next statement with the Like operator. For example, the following code searches for all cells in the range A1:C5 that use a font whose name starts with the letters Cour. When Microsoft Excel finds a match, it changes the font to Times New Roman.

Find (What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat)

Dim strWhat As String: strWhat = 
Dim rngFind As Range
Set rngFind = Worksheets("Sheet1").Range("A1:A10").Find(What:=strWhat)

Arguments

The following argument is required

What (String) - The data to search for. Can be a string or any Microsoft Excel data type.

The following arguments are optional

After (Range) - The cell after which you want the search to begin. This corresponds to the position of the active cell when a search is done from the user interface. Notice that After must be a single cell in the range. Remember that the search begins after this cell; the specified cell isn't searched until the method wraps back around to this cell. If you do not specify this argument, the search starts after the cell in the upper-left corner of the range.

LookIn (XlFindLookIn) - Can be one of the following XlFindLookIn constants: xlFormulas, xlValues, xlComments, or xlCommentsThreaded.

Possible Values are

xlComments Comments
xlCommentsThreaded Threaded comments
xlFormulas Formulas
xlFormulas2
xlValues Values

LookAt (XlLookAt) - Can be one of the following XlLookAt constants: xlWhole or xlPart.

Possible Values are xlPart - Match against any part of the search text, xlWhole - Match against the whole of the search text.

SearchOrder (XlSearchOrder) - Can be one of the following XlSearchOrder constants: xlByRows or xlByColumns.

Possible Values are xlByColumns - Searches down through a column, then moves to the next column, xlByRows - Searches across a row, then moves to the next row.

SearchDirection (XlSearchDirection) - The search direction.

Possible Values are xlNext - Search for next matching value in range, xlPrevious - Search for previous matching value in range.

MatchCase (Boolean) - True to make the search case-sensitive. The default value is False.

MatchByte (Boolean) - Used only if you have selected or installed double-byte language support. True to have double-byte characters match only double-byte characters. False to have double-byte characters match their single-byte equivalents.

SearchFormat - The search format