Can't make the formula work from apps scritp to google sheet

51 views
Skip to first unread message

Proiz

unread,
Sep 13, 2023, 4:11:55 PM9/13/23
to Google Apps Script Community
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?

Peter Berkhout

unread,
Sep 16, 2023, 2:10:54 PM9/16/23
to Google Apps Script Community
It looks like the closing ) is missing on this line: 
var key = sheet.getRange("E" + rigaCorrente).getValue()

Op woensdag 13 september 2023 om 22:11:55 UTC+2 schreef Proiz:

Daniel Paes

unread,
Sep 28, 2023, 6:55:54 AM9/28/23
to google-apps-sc...@googlegroups.com
something i have do it, its use formula in english, even if my formulas in google sheets its in my language... i dont know why, but the spreadsheet only accept the formula write from the app script in english.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/226d7bee-30b9-4d79-bbdd-fa422b131203n%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages