IFERROR

function IFERROR(arg1: any = null, arg2: any = null): number | string | boolean

Description

Returns value_if_error if expression is an error and the value of the expression itself otherwise.

Parameters

arg1anydefault: null

Is any value or expression or reference.

arg2anydefault: null

Is any value or expression or reference.

Returns

number | string | boolean

Try It

var oWorksheet = Api.GetActiveSheet();
var oFunction = Api.GetWorksheetFunction();
var stock = ["Stock", 0, 84];
var values = ["Total value", "$5.43", "$297.36"];
oWorksheet.GetRange("C1").SetValue("Unit Price");

for (var i = 0; i < stock.length; i++) {
   oWorksheet.GetRange("A" + (i + 1)).SetValue(stock[i]);
}
for (var j = 0; j < values.length; j++) {
   oWorksheet.GetRange("B" + (j + 1)).SetValue(values[j]);
}
for (var n = 1; n < values.length; n++) {
   var value1 = oWorksheet.GetRange("B" + (n + 1)).GetValue();
   var value2 = oWorksheet.GetRange("A" + (n + 1)).GetValue();
   oWorksheet.GetRange("C" + (n + 1)).SetValue(oFunction.IFERROR(value1/value2, "Out of stock"));
}

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).