Find Specific Cell Values

ou can use the Find method to search for specific values within a range of cells. This method works essentially the same as the EditOFind command in Excel. The Find method has several different parameters of which only the What parameter is required. You must specify the string for which you want to search as the value of the What parameter.

If you want to start searching from a specific cell, use the After parameter to reference the cell before where you want to start searching. If omitted, Excel starts the search with the top left cell in the range.

For the LookIn parameter, specify one of the XlFindLookIn constants to indicate what part of the cell to search. Type xlValues to look at cell values, xlComments to search attached comments, or xlFormulas to look at formulas.

You specify a value of xlWhole for the LookAt parameter to require Excel to match the entire contents of a cell. You specify xlPart if Excel should match a cell that contains a search string as part of the cell value.

Specify the appropriate XlSearchOrder constant to indicate whether to search by rows or columns xlByRows searches by rows and xlByColumns searches by columns.

You use the SearchDirection parameter to indicate the direction to search. A value of xlNext finds the next matching value in the worksheet. A value of xlPrevious finds the previous match.

Type a value of True for the MatchCase parameter if Excel should only match occurences with the same case, all uppercase, all lowercase, and so on. If you are using double-byte language support, type a value of True for the MatchByte parameter to only match double-byte characters with double-byte characters.

Using the SearchFormat parameter is a little more complex. If you assign this parameter a value of True, you need to specify the format for the Application. FindFormat object.

FIND SPECIFIC CELL VALUES

FIND SPECIFIC CELL VALUES

'-n Create a new subroutine.

L0 Type Range("A1:G16").Find, replacing Range("A1:G16") with the range of cells to search.

< Type What:="Boise", replacing Boise with the string you want to search for.

'-n Create a new subroutine.

Note: See Chapter 3 for information on creating subroutines.

L0 Type Range("A1:G16").Find, replacing Range("A1:G16") with the range of cells to search.

< Type What:="Boise", replacing Boise with the string you want to search for.

0 0

Post a comment