title: Google Script: Get Timestamp in Specific Column for ALL Selected Rows (Loop?)
body: <p>In Google Spreadsheet I want to create a timestamp in a specific column, if any value in that row is modified. I could manage that with the following code (Google Script):</p>
  
  <pre><code>function onEdit() {
    var s = SpreadsheetApp.getActiveSheet();
    var r = s.getActiveCell();
    var row = r.getRow()
    s.getRange('Z' + row).setValue(new Date()).setNumberFormat('dd.MM.yy, hh:mm'); //inserts a timestamp in column Z of the modified row
  }
  </code></pre>
  
  <p>I would like to extend the functionality if MORE rows than one are modified, eg. if more cells are inserted by copy/paste. Now only the first row gets it's timestamp.</p>
  
  <p>Do you have any ideas how I can process all selected rows? Maybe by loop?</p>
  
  <p>UPDATE: One step further:
  Is there a way to write the timestamp(s) only if the cell is empty!? Existing timestamps should not be overwritten.</p>
  
  <p>Br, Fred</p>