Removes a sheet tab from the spreadsheet.
class SpreadsheetApp method .deleteSheet()
SpreadsheetApp is the Apps Script service.
.deleteSheet() is the method name you will see after a dot in your code.
What it does
Why it's used
- Remove temporary import tabs after processing is done.
- Clean up old weekly tabs as part of a scheduled maintenance script.
Common errors
- Forgetting parentheses on deleteSheet. Write SpreadsheetApp.deleteSheet(), not SpreadsheetApp.deleteSheet or deleteSheet by itself.
- Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').deleteSheet().
- Adding spaces where they do not belong. Write SpreadsheetApp.deleteSheet(), not SpreadsheetApp .deleteSheet(), SpreadsheetApp.deleteSheet (), or SpreadsheetApp . deleteSheet().
- Wrong capitalization. Use SpreadsheetApp and deleteSheet, not spreadsheetapp or deletesheet.
2 Snippets using this methods
Explore
Related methods
-
.insertSheet()
Adds a new sheet tab to the spreadsheet.
-
.deleteRow()
Deletes a single row from the sheet.
-
.getSheets()
Returns every sheet tab in the spreadsheet.
-
.getSheetByName()
Finds a sheet tab by its name.
-
.clear()
Removes values, formatting, and notes from a range.
More Apps Script
2 Better Sheets tutorials
Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas
Automatically Delete All Sheets If Not Listed Name
Related blog posts
Written guides about SpreadsheetApp.deleteSheet().
Automate Row Deletion in Google Sheets with Apps Script
In this post, we'll cover how to remove rows automatically in Google Sheets using Apps Script, ensuring you save time and streamline your spreadsheet management. You're probably already familiar with the manual way of right-clicking and deleting rows, but there's a more efficient way to handle this—automation! Manual versus Semi-Automatic Deletion You may know that you can manually delete rows in Google Sheets by right-clicking and selecting "Delete row." You can even select multiple rows...
Read post →What's Better Than Google Sheets?
Nothing is better than Google Sheets. You just need to learn more about the unlimited power of Google Sheets. Functions, Formulas, Apps Script and more.
Read post →How To Use a 1-Cell Google Sheet
Introduction to Tiny Sheets a free google sheet add-on to make tiny spreadsheets. Delete unnecessary rows and columns easily.
Read post →