title: google script: copy paste values only range with offset
body: <p>I would like to implement a script that checks the values in column "D" of sheet "Review&amp;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.</p>
  
  <p>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.</p>
  
  <p>I am pretty new to google script with basic knowledge of it.</p>
  
  <p>I have implemented this code but it does not work:</p>
  
  <pre><code>function onEdit() {
   var s = SpreadsheetApp.getActiveSheet();
   if( s.getName() == "Review&amp;Trigger" ) {
    var r = s.getActiveCell();
    var y = s.getActiveRange();
    if( r.getColumn() == 4 &amp;&amp; y.getValue() == "Yes") {
    var nextCell = r.offset(0, 12);
    var range = s.getRange(r,nextCell);
    range.copyTo (range, {contentsOnly: true});
  source.clear();
    }
   }
  }
  </code></pre>
  
  <p>Any idea about how to fix the code? Many thanks in advance!</p>