I am converting some spreadsheets from Excel to Google Sheets, and there is a function I am trying to do which gets the code and apply the function. For example I have a list of codes in a column and the next 5 columns with texts. I want to type =myFunction("code")
and I would like to return the value with this formula =vlookup(code;A1:F30;3;0)
, that would return the column 3 with the row the code is.
I've tried these:
function myFunc(code) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var cell = sheet.getRange(getCell);
var test = cell.setFormula('=VLOOKUP('+code+';a1:b10;2;0)')
return test;
}
it says I don't have permission to call setFunction,
function gettext(code) {
var func = '=VLOOKUP("'+ code +'";\'VA-Texte\'!A1:I383;\'VA-Texte\'!E1;0)';
return func;
}
it prints the exact code I need, but does not act like a formula.