I want to delete all the rows that I don't need on Google Sheets, my data has a table header.
Thanks!
I believe your goal as follows.
In this case, how about the following sample script?
function muFunction() {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getRange("C:C").activate();
}
From I want to delete all the rows that I don't need on Google Sheets, my data has a table header., when you want to clear the rows except for the 1st header row, you can also use the following script. When the following script is run, the cells "C2:C" of "Sheet1" are cleared.
function muFunction2() {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getRange("C2:C").clearContent();
}
From What's the code equivalent for Command + shift + down?, in this case, I thought that the following script is the result you expect? When you use the following script, please select a cell and run the script. By this, the rows of the data range after the selected cell are selected.
function myFunction3() {
const activeRange = SpreadsheetApp.getActiveRange();
activeRange.offset(0, 0, activeRange.getNextDataCell(SpreadsheetApp.Direction.DOWN).getRow() - activeRange.getRow() + 1).activate();
}