Skip to main content

GetCellsCount

Returns a number of cells in the current range.

Syntax

expression.GetCellsCount();

expression - A variable that represents a ApiRange class.

Parameters

This method doesn't have any parameters.

Returns

number

Example

Count the total number of cells inside a selected range in a spreadsheet.

// How do I find out how many cells are in a range in a spreadsheet?

// Confirm the expected cell count by writing the total next to the filled range.

let worksheet = Api.GetActiveSheet();
let range = worksheet.GetRange("A1:D10");
range.SetValue("I was selected");
worksheet.GetRange("A11").SetValue("Cells count in the selected range should be 40: " + range.GetCellsCount());