0

I have formulas and validation in columns D, E, L, M and N. I want these formulas and validation to be automatic whenever I add rows using the option "Add more rows at the bottom", not using insert or copy & paste.

Sheets example

Is it possible to do it and if so can you please create a code for me?

  • This will copy formulas and values from the row above: webapps.stackexchange.com/questions/47171/… – eddyparkinson Dec 28 '13 at 5:41
  • I did try this but it didn't work. I've done my homework prior to asking the question. I can't seem to find an answer anywhere. And that's when I posted this question. – user54830 Dec 28 '13 at 9:54
1

Edit: fixed version of this: How to automatically insert a new row and retain functions/formulas from last row?

Also copies data validation rules.

Code

// global 
var ss = SpreadsheetApp.getActive();

function onOpen() {
  var menu = [{name:"Add New Last Row", functionName:"addRow"}];
  ss.addMenu("Extra", menu);
}

function addRow() {
  var sh = ss.getActiveSheet(), lRow = sh.getLastRow(); 
  var lCol = sh.getLastColumn(), range = sh.getRange(lRow,1,1,lCol);
  sh.insertRowsAfter(lRow, 1);
  range.copyTo(sh.getRange(lRow+1, 1, 1, lCol), {contentsOnly:false});
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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