I'm new at coding and I'm looking for the accurate syntax to define the range as the selected field.
I created a macro to change the color of the field (here for the color 'red'). I can do it on a defined field such as 'A1' or a group of fields such as'A1:Z40'.
But I tried to search for the right syntax if I want this macro works only for the current selected field.
What should I type instead of 'A1'?
function Rouge() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('**A1**').activate();
spreadsheet.getActiveRangeList().setBackground('#ff0000');
}
There's no A1-notation syntax for specifying the currently selected ranges because, by definition, it's not something that can be specified beforehand.
The value returned by Spreadsheet.GetActiveRangeList() will facilitate manipulating all of the cells that are currently selected.
Similarly, if you only want to manipulate the currently selected cell (i.e. the one with the dark border around it) you use Spreadsheet.getCurrentCell().