function listSheetNames() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheets =…
- User
function listSheetNames() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheets = ss.getSheets(); var sheetNames = sheets.map(sheet => [sheet.getName()]); //
// Check if the "Sheet List" tab already exists var sheetList = ss.getSheetByName("Sheet List");
if (!sheetList) { sheetList = ss.insertSheet("Sheet List"); } else { sheetList.clear(); }
// Output sheet names starting from A1 sheetList.getRange(1, 1, sheetNames.length, 1).setValues(sheetNames); }
this is apps script for gsheets - what does it do
Assistant
This Apps Script function creates a list of all sheet names in your Google Sheets spreadsheet. Specifically, it:
- Gets all sheets in the active spreadsheet
- Extracts just the names of these sheets
- Checks if a sheet called "Sheet List" exists
- If it doesn't exist, creates a new sheet with that name
- If it already exists, clears its contents
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.