Forum Discussion
nicolaspavie
Jul 23, 2024Copper Contributor
Excel scripting in JS : enhance getRange adress format resolution
Hi ! Just stumbled over a thing that I think could be interesting to be added in the Excel Javascript API, especially in the ranges' selection with addresses. For a script I'm writing to pars...
SergeiBaklan
Jul 23, 2024Diamond Contributor
As variant to select from A2 to end of the column
function main(workbook: ExcelScript.Workbook) {
const sheet = workbook.getActiveWorksheet()
const column = sheet.getRange("A:A")
const cell = sheet.getRange("A2")
const range = cell
.getResizedRange(
column.getRowCount() - cell.getRowIndex() -1,
0)
console.log(range.getRowCount())
}
In general range could be selected not only by addresses - getUsedRange(), getRangeByIndexes() plus resizings, etc.
I'd avoid selecting of entire cell or row, most probably it will be negatively affect performance.