Is there a way to populate a dropdown within a Google Sheets cell with a list of the tabs (sheets) inside the document?
Is there a way to populate a dropdown within a Google Sheets cell with a list of the tabs (sheets) inside the document?
Add this function to the script editor and save the project:
function get_sheets() {
return SpreadsheetApp.getActiveSpreadsheet().getSheets().map(function(x) {return x.getName();});}
Then you can add it to a cell. Here I select A2 as the dropdown formular. I simply select the range of column B.
And voila:
Go to Tools > Script editor
Paste into Code.gs:
/*** return sheet names for active document
* @customfunction
*/
function sheetnms() {
return SpreadsheetApp.getActiveSpreadsheet().getSheets().map(function(x) {return x.getName();});
}
Save as a project.
Go back the Google sheet.
Enter =sheetnms() into a cell.
When creating a data validation, get the list from the range of cells with the sheet names.
Note: there may be some delay for the list to update.