Range.Replace (Excel)

Returns a Boolean indicating characters in cells within the specified range. Using this method doesn't change either the selection or the active cell.

The settings for LookAt, SearchOrder, MatchCase, and MatchByte are saved each time you use this method. If you don't 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 that you use this method.

Replace (What, Replacement, LookAt, SearchOrder, MatchCase, MatchByte, SearchFormat, ReplaceFormat, FormulaVersion)


Worksheets("Sheet1").Columns("A").Replace _ 
 What:="SIN", Replacement:="COS", _ 
 SearchOrder:=xlByColumns, MatchCase:=True

Arguments

The following arguments are required:

What (String) - The string that you want Microsoft Excel to search for.

Replacement - The replacement string

Optional arguments

The following arguments are optional

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

Possible return 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 return 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.

MatchCase (Boolean) - True to make the search case-sensitive.

MatchByte (Boolean) - You can use this argument only if you have selected or installed double-byte language support in Microsoft Excel. 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 for the method

ReplaceFormat - The replace format for the method

FormulaVersion