Reputation: 3
I have a script to copy values from one sheet to another that works perfectly except I only want to clear the values in the source sheet, and leave the formula in place in cells E3, I3 and J3
function addLeavers()
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getRange("Add Leaver!A3:AM3");
var destSheet = ss.getSheetByName("Leavers");
destSheet.appendRow(source.getValues()[0]);
source.clear();
}
Upvotes: 0
Views: 300
Reputation: 201358
source
.If my understanding is correct, how about this modification? Please think of this as just one of several answers.
In this modification, the formulas are retrieve, and the range is clear using clear()
or clearContent()
. Then, the retrieved formulas are put to the range.
source.clear();
var formulas = source.getFormulas();
source.clear(): // or source.clearContent();
source.setFormulas(formulas);
If I misunderstood your question and this was not the result you want, I apologize.
Upvotes: 4