Conditionally copy data from one sheet to another with variable condition
<p>I am trying to figure out how I can write rows from one sheet to another if the value of, for example A4 on the destination sheet corresponds with a value in column A in the Source sheet. However, I only need to copy the last 19 columns and the columns in front of that are not needed. I do know how I can copy the wanted rows but the condition seems to be a constant value instead of a value that changes for every row in the destination sheet (so A4 value is different than A5, A6, etc.) I took a bit of the function from my sheet and copied it in here. </p>

<pre><code>function getPDdataupper() {
 var sheet = SpreadsheetApp.getActive().getSheetByName('SPR');

 var folder= DriveApp.getFolderById('Folder-id');
 var files = folder.getFilesByType(MimeType.GOOGLE_SHEETS);
 while (files.hasNext()) {
   var ssraw = SpreadsheetApp.open(files.next()); 
 }
    sheet.getRange(11,1,(sheet.getLastRow())-10,53).clearContent();
var sheetraw = ssraw.getSheetByName("SPR");
  var sheetl=SpreadsheetApp.getActive().getSheetByName('single line data1')    

var data = sheetl.getDataRange().getValues();{
            var val = new Array();
           for(n=0;n&lt;data.length;++n){
            if (data[n][1]=="'SPR'!A4");{ 
              val.push([[data[n][24]], [data[n][25]], [data[n][26]], [data[n][27]], [data[n][28]], [data[n][29]], [data[n][30]], [data[n][31]],
                [data[n][32]], [data[n][33]], [data[n][34]], [data[n][35]], [data[n][36]], [data[n][37]], [data[n][38]], [data[n][39]], [data[n][40]], [data[n][41]], [data[n][42]], [data[n][43]]]);
              }
          }


            sheet.getRange(7,35,1,1).setValues(val);

    }   
</code></pre>

<p>}</p>

<p>If someone could help me into the right direction to get the condition changed by every row it checks that would be great. Also, i'm not sure if I can use an Array now or if I have to use Appendrow.</p>

<p>Thanks,
Tim</p>