Share via


XmlMappedRange.Replace Method

Definition

Replaces the specified characters in the XmlMappedRange control with a new string.

public bool Replace (object What, object Replacement, object LookAt, object SearchOrder, object MatchCase, object MatchByte, object SearchFormat, object ReplaceFormat);
abstract member Replace : obj * obj * obj * obj * obj * obj * obj * obj -> bool
Public Function Replace (What As Object, Replacement As Object, Optional LookAt As Object, Optional SearchOrder As Object, Optional MatchCase As Object, Optional MatchByte As Object, Optional SearchFormat As Object, Optional ReplaceFormat As Object) As Boolean

Parameters

What
Object

The string you want Microsoft Office Excel to search for.

Replacement
Object

The replacement string.

LookAt
Object

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

SearchOrder
Object

Can be one of the following XlSearchOrder constants: xlByRows or xlByColumns.

MatchCase
Object

true to make the search case sensitive.

MatchByte
Object

You can use this argument only if you have selected or installed double-byte language support in Excel. true to have double-byte characters match only double-byte characters; false to have double-byte characters match their single-byte equivalents.

SearchFormat
Object

The search format for the method.

ReplaceFormat
Object

The replace format for the method.

Returns

true if the specified characters are in the XmlMappedRange control; otherwise, false.

Examples

The following code example uses the Replace method to replace the string "Smith" with the string "Jones" within an XmlMappedRange. This code example assumes that the current worksheet contains an XmlMappedRange named CustomerLastNameCell.

private void ReplaceSmith()
{
    this.CustomerLastNameCell.Value2 = "Walker, Smith, James";
    this.CustomerLastNameCell.Replace("Smith", "Jones");
}
Private Sub ReplaceSmith()
    Me.CustomerLastNameCell.Value2 = "Walker, Smith, James"
    Me.CustomerLastNameCell.Replace("Smith", "Jones")
End Sub

Remarks

Using this method does not 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 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.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to