I would like to implement a script that checks the values in column "D" of sheet "Review&Trigger". If the value is yes, then it copies the content only of the cells in the same row between columns E and P. Afterwards, it pastes the content to the same range.
For example: if the value in D5 (Important, this applies to any row of column D) is "Yes", then the script should copy the range E5:P5 and paste the values only to the same range E5:P5.
I am pretty new to google script with basic knowledge of it.
I have implemented this code but it does not work:
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Review&Trigger" ) {
var r = s.getActiveCell();
var y = s.getActiveRange();
if( r.getColumn() == 4 && y.getValue() == "Yes") {
var nextCell = r.offset(0, 12);
var range = s.getRange(r,nextCell);
range.copyTo (range, {contentsOnly: true});
source.clear();
}
}
}
Any idea about how to fix the code? Many thanks in advance!
var range = s.getRange(r,nextCell);
is a right way to usegetRange()
– Max Makhrov