SUBSTITUTE
Replaces existing text with new text in a text string.
Syntax
expression.SUBSTITUTE(arg1, arg2, arg3, arg4);
expression
- A variable that represents a ApiWorksheetFunction class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
arg1 | Required | ApiRange | ApiName | string | The text or the reference to a cell containing text in which the characters will be substituted. | |
arg2 | Required | ApiRange | ApiName | string | The existing text to replace. If the case of the original text does not match the case of text, the function will not replace the text. | |
arg3 | Required | ApiRange | ApiName | string | The text to replace the original text with. | |
arg4 | Optional | ApiRange | ApiName | string | Specifies which occurrence of the original text to replace. If omitted, every instance of the original text will be replaced. |
Returns
string
Example
- Code
- Result
let worksheet = Api.GetActiveSheet();
let func = Api.GetWorksheetFunction();
worksheet.GetRange("A1").SetValue(func.SUBSTITUTE("Online Office is a cloud business service portal", "Office", "portal"));