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

Removes a sheet tab from the spreadsheet.

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.

Explore

Related methods

Better Sheets tutorials

Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas

Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas

Automatically copy a spreadsheet tab to a whole new spreadsheet file, ge...
Automatically Delete All Sheets If Not Listed Name

Automatically Delete All Sheets If Not Listed Name

A raw, 1 shot take of figuring out how to automatically delete all sheet...

Related blog posts

Written guides about SpreadsheetApp.deleteSheet().

Browse the blog