I want to add a script in Google Spreadsheets that adds new row on the second line of every sheet within a Google Spreadsheet that contains multiple spreadsheets.

This will need to happen every day.


1 Answer 1


Try this code:

function AddRow() {
  //gets the spreadsheet which it's bound to
  var ssheet = SpreadsheetApp.getActiveSpreadsheet();  

  //gets all sheets in this spreadsheet
  var sheet = ssheet.getSheets();                      

  //browses all the sheets, until "i" is larger than the number of sheets
  for (var i = 0; i < sheet.length; i++)               
    //adds to the actual sheet a row AFTER the first row

and trigger it on a daily basis (like on 1 a.m.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.