0

I am trying to write a function to shorten VLOOKUP in the sheet, since I have to use it many times in different cells. I am getting this error in the following code:

function find(a) {
    var q = VLOOKUP(a,Rooms:Capacities,2,FLASE)
    return q
}

Any help is appreciated.

Pang
  • 9,564
  • 146
  • 81
  • 122
Mr Guitarisht
  • 11
  • 1
  • 5
  • I have altered the code to this, but I still get this error at the line defining q: function getCapacity(a) { var ss = SpreadsheetApp.getActive().getSheetByName('codeDATA'); var R = ss.getRange('A3:A58'); var C = ss.getRange('B3:B58'); var q = VLOOKUP(a,R:C,2,FALSE); return q; } – Mr Guitarisht Dec 10 '16 at 01:31

2 Answers2

0

This is a bit of a guess but could it be your function name. Sheets already has a find() function. Try changing the name to something like myfind(a)

Gordon
  • 1,165
  • 1
  • 7
  • 12
0

I had to re-write the script entirely, but it works now.

function getCapacity(a) {
  var data = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('codeDATA');
  var R = data.getRange(1,1,data.getLastRow(),2).getValues();
  var C = data.getRange(1, 2, data.getLastRow()).getValues();
  for (var i = 2; i < R.length; i++) {
      if (R[i][0] === a) {
       break
      }
    }
  return C[i]
}
Mr Guitarisht
  • 11
  • 1
  • 5