Skip to content Skip to sidebar Skip to footer

Get First Row Where Cola = Name, Colb = Secondname And Colc = Null(is Empty)

I'm very new to JavaScript so bear with me. I want an equation that searches multiple columns for specified values, not the same value across all columns. For example: ColA = Jame

Solution 1:

Try this:

c1,c2 and c3 are column number n1,n2 and n3 are values or strings or null and name is the sheetname.

functionfindRows(c1,n1,c2,n2,c3,n3,name) {
  var ss=SpreadsheetApp.getActive();
  var sh=ss.getSheetByName(name);
  var rg=sh.getDataRange();
  var vA=rg.getValues();
  var rA=[];
  for(var i=0;i<vA.length;i++) {
    if(vA[i][c1-1]==n1 && vA[i][c2-1]==n2 && vA[i][c3-1]==n3) {
      rA.push(i+1);
    }
  }
  return rA
}

functiontest() {
  Logger.log(findRows(1,10,2,2,3,null,'Sheet150'));
}

Post a Comment for "Get First Row Where Cola = Name, Colb = Secondname And Colc = Null(is Empty)"