Reputation: 140
TL;DR: I am looking for the equivalent of Excel's SHEET()
function for finding out the numerical index of the current sheet in Google Sheets.
If the sheet is the first in the list of sheets, then a formula needs to refer to a value in column 1 of another sheet. If it's the second sheet, column 2 of the other sheet, etc.
The formula I would use to do this in Excel would be: =ADDRESS(1,SHEET(),,,"Foo")
which would result in Foo!$a$1
on the first sheet and Foo!$a$2
on the second sheet, etc.
Upvotes: 1
Views: 56
Reputation: 140
Following @Saddles' suggestion I ended up adding:
function SHEET() {
return SpreadsheetApp.getActiveSheet().getIndex();
}
to my sheet's Apps Script library and that seems to have worked.
Upvotes: 0