Partager via


Range.Replace Method

Returns a Boolean indicating characters in cells within the specified range.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Function Replace ( _
    What As Object, _
    Replacement As Object, _
    LookAt As Object, _
    SearchOrder As Object, _
    MatchCase As Object, _
    MatchByte As Object, _
    SearchFormat As Object, _
    ReplaceFormat As Object _
) As Boolean
'Usage
Dim instance As Range
Dim What As Object
Dim Replacement As Object
Dim LookAt As Object
Dim SearchOrder As Object
Dim MatchCase As Object
Dim MatchByte As Object
Dim SearchFormat As Object
Dim ReplaceFormat As Object
Dim returnValue As Boolean

returnValue = instance.Replace(What, Replacement, _
    LookAt, SearchOrder, MatchCase, MatchByte, _
    SearchFormat, ReplaceFormat)
bool Replace(
    Object What,
    Object Replacement,
    Object LookAt,
    Object SearchOrder,
    Object MatchCase,
    Object MatchByte,
    Object SearchFormat,
    Object ReplaceFormat
)

Parameters

  • What
    Type: System.Object

    Required Object. The string you want Microsoft Excel to search for.

  • Replacement
    Type: System.Object

    Required Object. The replacement string.

  • LookAt
    Type: System.Object

    Optional Object. Can be one of the following XlLookAt constants: xlWhole or xlPart.

  • MatchCase
    Type: System.Object

    Optional Object. True to make the search case sensitive.

  • MatchByte
    Type: System.Object

    Optional Object. You can use this argument only if you’ve 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
    Type: System.Object

    Optional Object. The search format for the method.

  • ReplaceFormat
    Type: System.Object

    Optional Object. The replace format for the method.

Return Value

Type: System.Boolean

Remarks

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 you use this method.

See Also

Reference

Range Interface

Range Members

Microsoft.Office.Interop.Excel Namespace