Deletes multiple rows starting at a given position.
class SpreadsheetApp method .deleteRows()
SpreadsheetApp is the Apps Script service.
.deleteRows() is the method name you will see after a dot in your code.
What it does
Why it's used
- Bulk-remove empty or duplicate rows after a cleanup pass.
- Shrink a sheet after archiving old records elsewhere.
Common errors
- Forgetting parentheses on deleteRows. Write SpreadsheetApp.deleteRows(), not SpreadsheetApp.deleteRows or deleteRows by itself.
- Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').deleteRows().
- Adding spaces where they do not belong. Write SpreadsheetApp.deleteRows(), not SpreadsheetApp .deleteRows(), SpreadsheetApp.deleteRows (), or SpreadsheetApp . deleteRows().
- Wrong capitalization. Use SpreadsheetApp and deleteRows, not spreadsheetapp or deleterows.
Explore
Related methods
-
.deleteRow()
Deletes a single row from the sheet.
-
.insertRows()
Inserts one or more blank rows at a given position.
-
.getRow()
Returns the starting row index of a range.
-
.appendRow()
Adds a new row of data at the bottom of the sheet.
-
.deleteSheet()
Removes a sheet tab from the spreadsheet.
More Apps Script
Better Sheets tutorials
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.
Related blog posts
Written guides about SpreadsheetApp.deleteRows().
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 →Can ChatGPT Automate Spreadsheets?
Automate Google Sheets! Learn to create custom add-ons, decipher code, and automate daily tasks using Apps Scripts. Optimize your spreadsheets.
Read post →Automated Project Management in Google Sheets
When you have multiple people working on multiple tasks, and you want everyone to be on the page, what do you do? You can use a Google Sheet. But managing projects can be an intimidating task in Google Sheets. It's a lot of data entry, right? Especially when you have multiple people working on different tasks with different statuses across different projects. Data entry for multiple projects, with different people, tasks, and statuses – it gets messy fast! I'm no stranger to these issues...
Read post →