0

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.

cadbury4all
  • 9
  • 2
  • 4
  • 1
    Likely a dupe of: https://stackoverflow.com/questions/13605213/google-spreadsheets-iterate-over-range-append-string-to-each – dxdc Feb 25 '18 at 04:04
  • 2
    Possible duplicate of [Google Spreadsheets: Iterate over range, append string to each](https://stackoverflow.com/questions/13605213/google-spreadsheets-iterate-over-range-append-string-to-each) – peacetype Feb 25 '18 at 05:28

1 Answers1

0

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]);
    }
  }
}
Chris
  • 2,057
  • 1
  • 15
  • 25