title: How to change the contents of an active cell
body: <p>In a google apps script, I want to be able to enter an integer value (1-10), and then have the script change the cell where that value was entered to a string based on a lookup. Essentially this:</p>
  
  <p><img src="https://i.stack.imgur.com/whKVy.jpg" alt="enter image description here"></p>
  
  <p>Here's what I have, but it never does anything. I can't even get a cell to change its own text value.</p>
  
  <pre><code>function onEdit(event){
    var sheet = event.source.getActiveSheet();
    var editedCell = sheet.getActiveCell();
    var editedCellRange = SpreadsheetApp.getActiveSheet().getRange(editedCell);
  
    var columnToSortBy = 4;
  
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var Values = [ss.getRange('I2'),ss.getRange('I3'),ss.getRange('I4'),ss.getRange('I5'),ss.getRange('I6'),ss.getRange('I7'),ss.getRange('I8'),ss.getRange('I9'),ss.getRange('I10'),ss.getRange('I11')];  
    if(editedCell.getColumn() == columnToSortBy){   
      editedCellRange.setValue(Values[editedCellRange.getValue()-1]);
    }
  }
  </code></pre>
  
  <p>So <code>var Values</code> is an array holding the string values that should be displayed. When a cell in the 4th column is edited to contain an integer, then the script should look up the value of that integer position in the array, and then put the appropriate string in the edited cell. Can anyone show me what is wrong with my script (or a better way to write this in a script)?</p>