title: Script in Google Spreadsheets - VLOOKUP
body: <p>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:</p>
  
  <pre class="lang-js prettyprint-override"><code>for (var c = 5; c &lt; lstRow; c++) {
    var vlookupCell = "=VLOOKUP('"+sheet2.getRange(c,7).getValue()+"','"+NewSheetNm+"'!B:C,2,0)";
    sheet2.getRange(c,1).setValue(vlookupCell);
    CurrRow=CurrRow+1;
  }
  </code></pre>
  
  <p>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?</p>