What is appendRow in Google Sheets Apps Script?
appendRow adds one new row to the bottom of the first used table on a sheet, filling values left to right across columns. It is the quickest way to log an event, store a form response field set, or push one record without calculating the next row number manually.
When to use it
Use appendRow for single new records: log each onEdit event, save a webhook payload, add a form row from e.values, or queue a job entry with timestamp and user.
When to skip it
Skip appendRow when inserting many rows at once. Build a 2D array and setValues at getLastRow + 1 is faster. Use insertRowBefore when order in the middle of the sheet matters.
How it works
-
1
Call sheet.appendRow([col1, col2, col3]) with a flat array of cell values in column order.
-
2
Apps Script places the row after the current last row of the sheet table.
-
3
{:"Values types follow setValue rules"=>"strings, numbers, dates, booleans."}
-
4
Missing array slots leave trailing cells blank on that row.
-
5
For multi-column consistency, keep array order aligned with your header row.
-
6
Combine with LockService when concurrent triggers might append at once.
Examples in Google Sheets
Audit log
onEdit calls appendRow on a Log sheet with timestamp, user email, sheet name, and edited address from the event object.
Form row mapping
onFormSubmit maps e.values into [id, name, email, answer] and appendRow on Responses mirror tab.
Error queue
catch block appendRow on Errors with message and stack snippet for later review.
Better Sheets resources
Common mistakes
-
Array column order does not match headers, shifting data into wrong fields.
-
appendRow in a tight loop for thousands of imports instead of batch setValues.
-
Expecting appendRow to start at column B; it always starts at column A unless you pad with empty strings.
-
Not using LockService when two time triggers append simultaneously and interleave partial rows.
-
Appending to the wrong sheet because getActiveSheet changed during the run.
Frequently asked questions
- Does appendRow need getLastRow first?
- No. appendRow finds the next row automatically. getLastRow is useful when you use setValues instead.
- Can appendRow append multiple rows?
- One row per call. Loop or switch to setValues for bulk inserts.
- What sheet does appendRow use?
- The Sheet object you call it on. Get the tab with getSheetByName before appendRow.
- Does appendRow expand the sheet forever?
- Each append adds a row. Archive old data periodically on high-volume logs.
- Will appendRow trigger onEdit?
- It can, because the grid changes. Design onEdit to ignore the Log tab or script columns.
- Can I append formulas?
- Pass strings starting with = in the array. They become formulas in the new row.
- How is appendRow different from insertRowBefore?
- appendRow adds at the bottom. insertRowBefore shifts existing rows down at a chosen index.
- Why are my columns shifted?
- Your array length or order does not match the sheet layout. Pad early columns with empty strings if column A is unused.
Related Tutorials
Watch how appendRow works
How to Insert Multiple Rows in Google Sheets (Easy to Hard)
Convert Google Sheets into a REST API
Move Entire Row when a Cell is changed to "Yes" - The $75,000 Google Script
Dylan Asks: How to Automatically Delete Rows If Cell Contains Value
Scrape Google Maps
Calculate ROAS in Google Sheets
Related blog posts
Guides that explain appendRow in more depth.
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 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 →Related terms
Google Sheets automation
Automation means work happens without repeating the same clicks every day: imports update, emails send, rows move, and dashboards refresh. In Sheets, automation usually stacks built-in features, Apps Script, and sometimes the Sheets API or add-ons. Start with the lightest tool that still solves the job.
Read guide →Apps Script triggers
Triggers tell Apps Script when to run a function: on edit, on open, on a schedule, or when a form is submitted. Simple triggers use reserved names like onEdit. Installable triggers are created in the Apps Script Triggers page and can do more, including running as a specific user or on a timer.
Read guide →Google Sheets workflows
A workflow is the path work takes through your sheet: intake, review, approval, done. Good workflows use consistent columns, statuses everyone understands, and just enough automation to move tasks forward without hiding steps from the team.
Read guide →MailApp
MailApp is an Apps Script service that sends email from your Google account without opening Gmail. You call MailApp.sendEmail with a recipient, subject, and body, often using cell values as the content. It is the fastest way to notify someone when a row is added or a deadline hits in a tracker.
Read guide →Done reading about appendRow?
Membership unlocks 600+ tutorials, unlimited generators, and every template. Practical lessons. Zero fluff.
Need this once
Jump to a free tool or a single tutorial for this topic.
Learning Sheets for real
Unlock the full library, generators, and templates with membership.