title: Insert row below based on the column value using google scripts
body: <p>I stuck with this. Seems easy at first then I got lost! </p>
  
  <p>What I am aiming for:</p>
  
  <ul>
  <li>to insert a row(s) based on a cell value (Col C) -- insert row(s) below</li>
  <li>after a new row(s) is inserted, copy the data from previous row + string value from previous row, removing that value as well from the previous row. </li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/w2FHJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w2FHJ.png" alt="enter image description here"></a></p>
  
  <p>I am trying to use this formula but I got lost...</p>
  
  <pre><code>function addRows(){
    var ss = SpreadsheetApp.getActive();
    var sheet1 = ss.getSheets()[1];
    var dataRange = sheet1.getDataRange();
    var dataValues = dataRange.getValues();
  
    for (var i = 0; i&lt;dataValues.length; i++) {
      for (var j= 0; j&lt;dataValues.length; i++) {
        /* If blank or 0 - zero, skip */
        if (dataValues[i][3] == "" || dataValues[i][3]== 0) {continue;}
        /* If value is &gt;=1, insert new row(s) below the active row */
        if (dataValues[i][3] &gt;=1) { 
        sheet1.insertRowAfter(i);
        sheet1.getRange(...) // copy the data from previous + string  
        }
      }
    }
  }
  </code></pre>