I've a multi-dimensional array sheetValues[][] created using .getValues() on the origination sheet. I'd like to copy the values from the sheetValues array into the destination sheet. How could I push the contents of each row of the sheetValues array into the destination sheet?
What function allows me to push each row of the array, one at a time (after checking for an IF condition) into the corresponding range of the destination sheet?
Here is the code snippet:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Source Sheet"); //Source sheet that has all data
var lastRow = sheet.getLastRow(); //last row number of Source sheet
var sheetValues = sheet.getRange(1, 1, lastRow, 18).getDisplayValues; //Copy Display values to an array; getDisplayValues() is used instead of getValues() to ignore formulas in the source cells such as "IMPORTRANGE"
var targetSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetbyName('Target Sheet'); //destination sheet
var currentRow = targetSheet.getLastRow(); //current last row of the destination sheet (start copying after this row)
var target = targetSheet.getRange(currentRow+1, 1); //target range where the copying of data should begin in destination sheet
loop through each row of the array (sheetValues) to check if the status (column I) is 'On Target'; if yes, copy that entire row to the target range defined above
for (var i = 0; i <= lastRow; i++) {
if (sheetValues[i][9] == 'On Target') {
How do I copy/push the entire row at once (column 1 - 18) directly into the target range (currentRow, columns 1-18)? What function do I use?
}
currentRow++;
}