jeudi 15 mars 2018

Google Apps Script Copy a range to another sheet based on the value of a cell

I have a table in a sheet in which I have a vlookup to check against another sheet which contains the same data and identify if there are any missing rows (discrepancy).

I want to copy and paste the missing rows identified with the vlookup formula: column I = "#N/A"

I am stuck with the following code, any help is greatly appreciated:

function CopyMissingRows(e) {
  if (e.values[8] == '#N/A') { 
    // do something
     var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('A2:G2').activate();
  var currentCell = spreadsheet.getCurrentCell();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Good events'), true);
  spreadsheet.getRange('Sales cal').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
  }
  else {
    // do something else
  }

Aucun commentaire:

Enregistrer un commentaire