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
Is the range of cells you want evaluated.
- arg2
any
null Is the condition or criteria in the form of a number, expression, or text that defines which cells will be added.
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"));