function FormSmartInfrastructures() {
var spreadsheet = SpreadsheetApp.getActive();
var sheet = spreadsheet.getSheetByName("Foglio1");
var rigaCorrente = sheet.getLastRow();
spreadsheet.getRange('A1').activate();
spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate();
spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.NEXT).activate();
spreadsheet.getCurrentCell().offset(0,1).activate();
var key = sheet.getRange("E" + rigaCorrente).getValue()
spreadsheet.getCurrentCell().setFormula('=CERCA.VERT("'+key+'";Foglio2!$A$2:$B$11;2;FALSO)');
};
It displays an error. The formula is written in the right way, if I copy the text and paste
it into another cell, it works, but in the currentcell it gives me an error.
Any tips?