Replace
Replaces specific information to another one in a range.
Syntax
expression.Replace(oReplaceData);
expression
- A variable that represents a ApiRange class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
oReplaceData | Required | ReplaceData | The data used to make search and replace. |
Returns
ApiRange | null
Example
This example replaces specific information to another one in a range.
- Code
- Result
let worksheet = Api.GetActiveSheet();
worksheet.GetRange("B1").SetValue(2014);
worksheet.GetRange("C1").SetValue(2015);
worksheet.GetRange("D1").SetValue(2016);
worksheet.GetRange("A2").SetValue("Projected Revenue");
worksheet.GetRange("A3").SetValue("Estimated Costs");
worksheet.GetRange("A4").SetValue("Cost price");
worksheet.GetRange("B2").SetValue(200);
worksheet.GetRange("B3").SetValue(250);
worksheet.GetRange("B4").SetValue(50);
worksheet.GetRange("C2").SetValue(200);
worksheet.GetRange("C3").SetValue(260);
worksheet.GetRange("C4").SetValue(120);
worksheet.GetRange("D2").SetValue(200);
worksheet.GetRange("D3").SetValue(200);
worksheet.GetRange("D4").SetValue(160);
let range = worksheet.GetRange("A2:D4");
let replaceData = {
What: "200",
Replacement: "0",
LookAt: "xlWhole",
SearchOrder: "xlByColumns",
SearchDirection: "xlNext",
MatchCase: true,
ReplaceAll: true
};
range.Replace(replaceData);