mercredi 29 avril 2020

Google Sheet Script: For Loop with If condition

I have a table with a lot of data from which I want to extract specific data into a separate tab, basically an If formula with a VLOOKUP just in a script. Col 23 is called Decision Meeting with options "Offer" and "Reject", and I want to extract each case that receives an "Offer" into the other sheet. I've written the code below, but for some reason it copies all cases, regardless of the content in (i,23). I hope someone can help:

function Offers() {

  var app = SpreadsheetApp;
  var Active = app.getActiveSpreadsheet().getSheetByName("Active");
  var Test = app.getActiveSpreadsheet().getSheetByName("Test");

  for (var i = 2 ; i<15 ; i++) {

    var DecisionMeeting = Active.getRange(i, 23).getValue();

    if(DecisionMeeting = "Offer"){
      Active.getRange(i, 1).copyTo(Test.getRange(i+2,1));
    }
  }
};

Aucun commentaire:

Enregistrer un commentaire