title: Set value of active cell in Google sheets script
body: <p>I want to create a formula which creates a timestamp on a certain cell change. The code below is okay for that. What I want to do now is anchor that timestamp to the sheet by converting the formula to plain text.</p>
  
  <p>If you would do it manually you would select the timestamps, copy them and paste them as values.</p>
  
  <p>I don't want to do it manually so I created the script below. It tries to overwrite the currenct active cell. Does anybody have an idea how to get this working?</p>
  
  <p>Thanks</p>
  
  <pre><code>function cvTimestamp(value) {
    var timezone = "GMT+1";
    var timestamp_format = "dd-MM-yyyy HH:mm:ss"; // Timestamp Format. 
  
  
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheets()[0];
  
  
    var date = Utilities.formatDate(new Date(), timezone, timestamp_format);
  
    return date
  
    // Returns the active cell
    var cell = sheet.getActiveCell();
    // try to write date to the active cell as a value.
    cell.setValue(date);
  
  }
  </code></pre>