8

I am looking for a way to automatically create a new row on top of older rows each day.

Inside of this row should be the current date.

2
  • 1
    Were you able to implement my solution? Sep 1, 2013 at 18:30
  • 1
    Approximately 340 rows were added since you asked this question..... Dec 25, 2014 at 7:40

1 Answer 1

10

With this little snippet it is possible. Add the code by selecting tools>Script editor in the spreadsheet. Make sure to press the bug button:

enter image description here

Code

// for the active sheet (in essence the first)
function onTop() {
  var ss = SpreadsheetApp.getActiveSheet();
  ss.insertRows(2);
  var date = Utilities.formatDate(new Date(), "GMT+2", "dd/MM/yyyy")
  ss.getRange("A2").setValue(date);  
}

// for a specific sheet
function onTop() {
  var sh = SpreadsheetApp.getActive().getSheetByName("TEST");
  sh.insertRows(2);
  var date = Utilities.formatDate(new Date(), "GMT+2", "dd/MM/yyyy")
  sh.getRange("A2").setValue(date);  
}

Triggers

In the script editor, choose the following menu option:
enter image description here

and set the trigger as follows (or however you choose): enter image description here

Example

I've created an example file for you: on top

Remark

You have to return tomorrow to check it though =)

3
  • Hi Jacob! How would I modify this script to reference a particular tab? Thanks. :)
    – Drewdavid
    Feb 24, 2017 at 17:10
  • 1
    Hi @Drewdavid, see code I've added. Feb 24, 2017 at 19:12
  • How do I set getRange(x) to below the last updated row? Like I want to update the sheet at the bottom. Nov 23, 2019 at 12:14

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.