Is it possible to create named ranges in Google sheets using google script? I would then want the spreadsheet to be able to use these in formulas.
Asked
Active
Viewed 8,250 times
5
-
Possible duplicate of [setNamedRange() outside of the spreadsheet container?](http://stackoverflow.com/questions/12323961/setnamedrange-outside-of-the-spreadsheet-container) – Rubén Nov 27 '16 at 15:51
2 Answers
2
You may want to check out this post:
setNamedRange() outside of the spreadsheet container?
and see if that helps you ..
1
Class SpreadSheet has the method setNamedRange(name, Range) that can be used.
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.setNamedRange("myNamedRange", SpreadsheetApp.getActiveRange());
Link to the Google Documentation: https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet?hl=en#setnamedrangename,-range
With me the pitfall was that I thought the method setNamedRange() belonged to the Class Range or Class Sheet. But turns out it belongs to the SpreadSheet Class.

Juuso Nykänen
- 369
- 2
- 12