Domanda

I have a for loop that we're trying to run that identifies the last row on another sheet, and populates a VLOOKUP in the cell next to it. For some reason I keep getting a variable error. Here's the code:

for (var c = 5; c < lstRow; c++) {
  var vlookupCell = "=VLOOKUP('"+sheet2.getRange(c,7).getValue()+"','"+NewSheetNm+"'!B:C,2,0)";
  sheet2.getRange(c,1).setValue(vlookupCell);
  CurrRow=CurrRow+1;
}

The variable "NewSheetNm" lives in the beginning of this function. This is just the last part of this current function. Anyone have any ideas why this won't work?

È stato utile?

Soluzione

What error is being generated?

The best would be to use the method setFormula(formula):

...
sheet2.getRange(c, 1).setFormula(vlookupCell);
...
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top