Google Sheets - how to insert data into the last row with Apps Script (programmatically)

0 points
Created by:

This article will show you how to programmatically insert data into the last row in Google Sheets (Apps Script).

Practical example

In the example below, we will use the sheet.getLastRow() method that returns the last row of data.
Thanks to this, we know where, for example, the last row of the table is and we can insert the data into the row below.

Google Sheets - how to add checkbox


Code used in the example: 

function myFunction() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = spreadsheet.getActiveSheet();

  var value = new Date(); // value you want to insert

  sheet.getRange(sheet.getLastRow() + 1).setValues([value]);

Google Sheets

Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂