How to get table range in Google sheet (NOT VALUES)

Viewed 18

var tableRange = "B2:G998"

How to write a script to get the table range without getting the values, what I want to the cells range only which is 'B2:G998'

My problem is when everytime I fixed the tableRange in the code for the appscript, everytime I delete a row or column, it will also obviously made the script won't run of the fixed value I entered in the script. How can I write the script to make get the Cell ranges except for the header or the ROW 1.

1 Answers

You can use getDataRange with Offset:

const dataRange=SpreadsheetApp.getActiveSheet().getDataRange(),
  dataRangeWithoutHeader=dataRange.offset(1, 0,dataRange.getNumRows()-1);
console.log(dataRangeWithoutHeader.getA1Notation())
Related