Inserts one or more blank rows at a given position.
class SpreadsheetApp method .insertRows()
SpreadsheetApp is the Apps Script service.
.insertRows() is the method name you will see after a dot in your code.
What it does
Why it's used
- Make room for a new block of data in the middle of a sheet.
- Shift rows down before inserting a header or summary section.
Common errors
- Forgetting parentheses on insertRows. Write SpreadsheetApp.insertRows(), not SpreadsheetApp.insertRows or insertRows by itself.
- Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').insertRows().
- Adding spaces where they do not belong. Write SpreadsheetApp.insertRows(), not SpreadsheetApp .insertRows(), SpreadsheetApp.insertRows (), or SpreadsheetApp . insertRows().
- Wrong capitalization. Use SpreadsheetApp and insertRows, not spreadsheetapp or insertrows.
Explore
Related methods
-
.insertColumns()
Inserts one or more blank columns at a given position.
-
.deleteRows()
Deletes multiple rows starting at a given position.
-
.appendRow()
Adds a new row of data at the bottom of the sheet.
-
.insertSheet()
Adds a new sheet tab to the spreadsheet.
-
.deleteRow()
Deletes a single row from the sheet.
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.insertRows().
How to Use Google Sheets as a Website Database
Did you know you can use Google Apps Script to turn a Google Sheet into a free, auto-syncing database for your website? This guide shows you exactly how to set it up. You’ll prepare your spreadsheet, write a few lines of code and publish your site. Don’t worry if you’re not a developer, we’ll walk you through it. Why Use Google Sheets as a Database? For small projects, Google Sheets offers many advantages over traditional databases: * Free hosting and storage * Easy to edit data without...
Read post →How to reference a different Google Spreadsheet in Apps Script?
Transferring Data Between Cells in Different Spreadsheets
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 →