You can copy formulas just as easily you copy values, just use Range.getFormula()
and Range.setFormula()
instead of .getValue()
and .setValue()
. See documentation on spreadsheet service.
Inserting a row below the last one is pretty basic, use insertRowAfter and getLastRow in a simple script.
EDIT : in case you don't find it, here is an example of another simple way to do it, copying everything in one step
function duplicateLastRow(){
var ss = SpreadsheetApp.getActiveSheet();
ss.insertRowAfter(ss.getLastRow());
ss.getRange(ss.getLastRow(),1,1,ss.getLastColumn()).copyTo(ss.getRange(ss.getLastRow()+1,1));
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…