class SpreadsheetApp method .getLastRow()

SpreadsheetApp is the Apps Script service.

.getLastRow() is the method name you will see after a dot in your code.

What it does

Returns the row number of the last row that has content.

Why it's used

  • Find where the data ends so you append on the next empty line.
  • Avoid overwriting rows when new records come in daily.

Common errors

  • Forgetting parentheses on getLastRow. Write SpreadsheetApp.getLastRow(), not SpreadsheetApp.getLastRow or getLastRow by itself.
  • Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').getLastRow().
  • Adding spaces where they do not belong. Write SpreadsheetApp.getLastRow(), not SpreadsheetApp .getLastRow(), SpreadsheetApp.getLastRow (), or SpreadsheetApp . getLastRow().
  • Wrong capitalization. Use SpreadsheetApp and getLastRow, not spreadsheetapp or getlastrow.

Explore

Related methods

  • .getLastColumn()

    Returns the column number of the last column that has content.

  • .getMaxRows()

    Returns the total number of rows the sheet can hold.

  • .getRow()

    Returns the starting row index of a range.

  • .getNumRows()

    Returns how many rows are in a range.

  • .appendRow()

    Adds a new row of data at the bottom of the sheet.

Better Sheets tutorials

Add Click Tracking To Your Google Sheets | Bitly in a Google Sheet

Add Click Tracking To Your Google Sheets | Bitly in a Google Sheet

Create a click Edit: Google changed how the redirect is handled. It no l...
Add NPS to Your Google Site

Add NPS to Your Google Site

Create buttons on your Google Site to get an NPS, or Net Promoter Score ...
Automate Google Sheets With Zero Experience

Automate Google Sheets With Zero Experience

By the end of this video you should be knowledgeable about how to automa...
Automate Move Blank Rows

Automate Move Blank Rows

Automate the apps script we just created that moves blank rows from one ...
Basic CRM - Add a Powerful Script To Move Row Based on Status

Basic CRM - Add a Powerful Script To Move Row Based on Status

we're going to be adding a very powerful script to our CRMs or any datab...
Better Sheets Videos Checklist

Better Sheets Videos Checklist

How to create a video checklist. Create a sheet with check boxes that yo...
Build a Job Status Checker API in 15 Minutes

Build a Job Status Checker API in 15 Minutes

The video tutorial demonstrates how to leverage Google Sheets and Google...
Build a License Key Generator and API in 20 Minutes

Build a License Key Generator and API in 20 Minutes

How to leverage Apps Script to create an API in less than 20 minutes. Cr...
Create a PR Agency From Scratch

Create a PR Agency From Scratch

Go from nothing to a working PR agency. Capture sites, and Send email vi...
Dylan Asks: How to Automatically Delete Rows If Cell Contains Value

Dylan Asks: How to Automatically Delete Rows If Cell Contains Value

Find out how to automatically delete rows based on a cell's value. We do...
Google Maps Scraper for Outreach

Google Maps Scraper for Outreach

Get this fun template to search on google maps via API, and quickly mess...
Google Sheets Stories? No! But we'll add timestamped video notes to your google sheets.

Google Sheets Stories? No! But we'll add timestamped video notes to your google sheets.

There was a stories craze. Every app/platform/business was adding 24 hou...
Hold a Giveaway Raffle in a Google Sheet

Hold a Giveaway Raffle in a Google Sheet

Get a random winner from a list of names. Also great to randomize tasks ...
How To Change Date Format Automatically

How To Change Date Format Automatically

Create automations to change date format based on the format you want, i...
How to Copy To New Tab When Checked

How to Copy To New Tab When Checked

Copy text from one tab to another based on a checkbox being checked.
How To Format Sheets for Notes

How To Format Sheets for Notes

Create sortable notes in Three ways.  1. By adding the original word ove...
How to Format Timestamp to Day and Month

How to Format Timestamp to Day and Month

Create a formatted timestamp to the full name of the day and month. Form...
How to Power Testimonials with Google Forms and Sheets

How to Power Testimonials with Google Forms and Sheets

I show you how I use a Google Form and a Google Sheet to power the testi...
Introducing SheetFools

Introducing SheetFools

Free google sheets automations pranks you can use right now. Launching p...
LinkTree in a Google Sheet

LinkTree in a Google Sheet

This tool will allows you to share multiple links on your social media.
Move Blank Rows

Move Blank Rows

Apps Script function to move all blank rows if a certain column is not f...
Move Entire Row when a Cell is changed to "Yes" - The $75,000 Google Script

Move Entire Row when a Cell is changed to "Yes" - The $75,000 Google Script

This is one of the most popular asked first "automations". How to move a...
Send a Daily Email with Inspiring Quote - A Little Pick Me Up

Send a Daily Email with Inspiring Quote - A Little Pick Me Up

Created a daily email with a motivational quote in the subject.
Sheet Stories / Video Notes + Clear 24 Hour Old Videos

Sheet Stories / Video Notes + Clear 24 Hour Old Videos

Revolutionary Method to Manage Your Video Stories! Learn how to delete o...
Spreadsheet Automation for Beginners

Spreadsheet Automation for Beginners

I start off this video with the idea to show beginners how to automate e...
Tag Emails From A List of Members in Google Sheets

Tag Emails From A List of Members in Google Sheets

Add labels to gmail emails you get from email addresses you put in a Goo...
Track Every Edit (Almost)

Track Every Edit (Almost)

Create a Log sheet in Google Sheets
Twitter App Clone in a Google Sheet

Twitter App Clone in a Google Sheet

I built a twitter clone in Google Sheets

Related blog posts

Written guides about SpreadsheetApp.getLastRow().

Browse the blog