Search code examples
google-apps-scriptgoogle-sheetsgoogle-sheets-macros

"Currentregion" concept in Google Sheets script language


From inside Google Sheets Script, I am trying to name a variable-sized matrix on the worksheet. In EXCEL VBA, I would go to the top left most cell and select the whole matrix using activecell.currentregion.select. This would select the whole matrix (e.g. D5:L50) on the worksheet, which I could then name.

Is there the same ability in Google Sheets script language. If not, can anyone figure out how to do this?


Solution

  • var spreadsheet = SpreadsheetApp.getActive();
    spreadsheet.getRange('D5:L50').activate();
    

    you can use macro under:

    • Tools > Macros > Record macro > and then make your selection > save macro > edit macro