0
votes

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 row at a time (after checking for an IF condition on a cell in each row) into the corresponding range of the destination sheet?

Your help is much appreciated.

1

1 Answers

0
votes

Here is a simple example of how to do what you asked. It runs through the array and can do a check on a column of a specific row, then appends it to the bottom of newSheet.

function getSetRows() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var values = sheet.getDataRange().getValues();

  var newSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Some Sheet");

  var rows = [];
  for (var i = 0; i < values.length; i++) {
    if (values[i][1] === "Something") { //Second number is the column number (starts from 1 on the left, 1 = col A)
      newSheet.appendRow(values[i][1]);
    }
  }
}