문제

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?

도움이 되었습니까?

해결책

What error is being generated?

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

...
sheet2.getRange(c, 1).setFormula(vlookupCell);
...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top