title: How to make my 'Show and hide rows' script function properly in Google Sheets
body: <p>I am trying to have a script in (google sheets) sheet "Info Pull" show/hide rows based on the contents of Column C.</p>
  
  <p>Currently I am running the following formula in Column C:</p>
  
  <pre><code>=if(or(len(H47)&gt;0,len(I47)&gt;0,len(J47)&gt;0,len(K47)&gt;0),"unhide","hide")
  </code></pre>
  
  <p>which produces either 'hide' or 'unhide' depending on whether or not cells H,I,J,and K 47 are returning a value.</p>
  
  <p>If any of the aforementioned cells return a value, the corresponding cell in Column C turns to 'unhide' and vice-versa if all the cells return no value. </p>
  
  <p>I've been trying to have this script hide/unhide the rows based on the contents of Column C however, the script is only partially functioning. </p>
  
  <p>If I actively type 'hide' into a C cell, the row will hide. However, if I paste 10 rows worth of 'hide' into 10 C cells, only the first row will hide. Likewise, the script is not re-evaluating and hiding/unhiding based off of the changing results of the IF formula. If I depopulate cell H47, turning C47 to hide, the cell does not hide. </p>
  
  <p>Also, if I set cell A1 to 'hide' and paste '=$A$1' in a group of cells in Column C, only the first cell in the group will hide and it will not unhide if I set A1 to 'unhide'. I think this may have something to do with my trigger but I am relatively new to scripting and am unsure.</p>
  
  <pre><code>function onEdit(e) {
    hideAndShowRows(e);
  }
  
      function hideAndShowRows(e) {
  
    var sheetsToWatch = ['Info Pull'];
    var columnToWatch = 3;
  
    var sheet = e.range.getSheet();
    if (sheetsToWatch.indexOf(sheet.getName()) &lt; 0)  {
      return;
    }
    var editedRow = e.range.getRow();
    var cellToWatch = sheet.getRange(editedRow, columnToWatch);
    if (cellToWatch.getValue().toLowerCase() === 'hide') {
      sheet.hideRows(editedRow);
    }
    if (cellToWatch.getValue().toLowerCase() === 'unhide') {
      sheet.showRows(editedRow);
    }
  }
  </code></pre>
  
  <p>I would like the cells to hide/unhide based off of whether or not the formula in Column C returns hide/unhide.</p>