SUMIF

function SUMIF(arg1: ApiRange = null, arg2: any = null, arg3: ApiRange = null): number | string | boolean

Description

Adds the cells specified by a given condition or criteria.

Parameters

arg1ApiRangedefault: null

Is the range of cells you want evaluated.

arg2anydefault: null

Is the condition or criteria in the form of a number, expression, or text that defines which cells will be added.

arg3ApiRangedefault: null

Are the actual cells to sum. If omitted, the cells in range are used.

Returns

number | string | boolean

Try It

var oWorksheet = Api.GetActiveSheet();
var product = ["Product", "Apple", "Orange", "Banana"]
var totalValue = ["Total Value", "$736.00", "$924.00", "$888.00"];

for (var i = 0; i < product.length; i++) {
   oWorksheet.GetRange("A" + (i + 1)).SetValue(product[i]);
}
for (var n = 0; n < totalValue.length; n++) {
   oWorksheet.GetRange("B" + (n + 1)).SetValue(totalValue[n]);
}

var oFunction = Api.GetWorksheetFunction();
var oRange = oWorksheet.GetRange("B2:B4");
oWorksheet.GetRange("C4").SetValue(oFunction.SUMIF(oRange, ">800"));

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).