title: set row destination when conditionally copying (google sheets)
body: <p>All.</p>
  
  <p>I'm a complete novice at scripting but through trial and error have managed to adapt a script I found for splitting a document into separate sheets based on a condition of <code>column D</code>.</p>
  
  <p>The sheet to be split is called <code>MASTER</code>, and I've already adapted a script to create the relevant tabs for each condition of <code>column D</code> (they are just numbers).</p>
  
  <p>What I'm not able to do is to set the data to be pasted in to the new sheets from <code>row 8</code> down (rather than <code>row 1</code>) - this is because I want each of the new sheets to have a static header occupying the first 7 rows. Probably a stupid question, but I can't figure it out and it would be great if I could.</p>
  
  <p>the existing code is:</p>
  
  <pre><code>var ss=SpreadsheetApp.getActiveSpreadsheet();
  var master = ss.getSheetByName('MASTER');
  var colWidth = master.getMaxColumns();
  
  
  function copyRowsOnCondition() {
    var data = master.getDataRange().getValues();
    for(n=7;n&lt;data.length;++n){
      if(data[n][3].length&lt;16){ 
      Logger.log(data[n][3])
       var dest = ss.getSheetByName(data[n][3].toString().replace(/ /g,''));
       var destRange = dest.getRange(dest.getLastRow()+1,1);
       master.getRange(n+1,1,1,colWidth).copyTo(destRange); 
       }
    }// loop
  }
  </code></pre>
  
  <p>Any help massively appreciated.</p>
  
  <p>Thanks</p>