Reputation: 83
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?
Upvotes: 2
Views: 1062
Reputation: 82
SpreadsheetApp.Range
getDataRegion():
Returns a copy of the range expanded in the four cardinal Direction
s to cover all
adjacent cells with data in them. If the range is surrounded by empty cells not including those
along the diagonals, the range itself is returned. This is similar to selecting the range and
typing Ctrl+A
in the editor.
Upvotes: 1
Reputation: 23
The question is: how do you refer to a range which contains values and most importantly, the range may change as user add or remove contents. In Excel VBA, this is dealt with a built-in function called "currentregion". I'm also curious if there is a equivalent in GS.
Upvotes: 0
Reputation: 1
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('D5:L50').activate();
you can use macro under:
Upvotes: 1