Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9786

Cell formula which returns the number of sheets

$
0
0

I'm trying to add some "validation" to a google sheet to prevent errors from creeping in as the sheet is edited (think assertion when programming).

Because of the way my sheet is structured to do this validation it would be useful to know the number of sheets in the current workbook. Is it possible to do this?

Approaches tried:

Excel-compatible function

Excel provides the functions =SHEETS() for this purpose (https://exceljet.net/excel-functions/excel-sheet-function). But this function doesn't exist in sheets

Custom function

This post on reddit suggests using the following functions in scripts:

function getNumSheets() {  return SpreadsheetApp.getActiveSpreadsheet().getSheets().length;}

This works - but it doesn't get updated when the number of sheets change - unless you force it to recalculate.

I'm leaning towards doing my validation "in code" rather than in the equation language and running it every time I want to do my tests....


Viewing all articles
Browse latest Browse all 9786

Trending Articles