COUNTIF
function COUNTIF(arg1: ApiRange = null, arg2: number | string = null): number
Description
Counts a number of cells within a range that meet the given condition.
Parameters
The range of cells to count nonblank cells.
- arg2
number | string
null The condition in the form of a number, expression, or text that defines which cells will be counted.
Returns
number
Try It
var oWorksheet = Api.GetActiveSheet();
var oFunction = Api.GetWorksheetFunction();
var fruits = ["Apples", "Oranges", "Bananas"];
var numbers = [45, 6, 8];
for (var i = 0; i < fruits.length; i++) {
oWorksheet.GetRange("A" + (i + 1)).SetValue(fruits[i]);
}
for (var j = 0; j < numbers.length; j++) {
oWorksheet.GetRange("B" + (j + 1)).SetValue(numbers[j]);
}
var oRange = oWorksheet.GetRange("A1:B3");
oWorksheet.GetRange("D3").SetValue(oFunction.COUNTIF(oRange, "*es"));