I have this script to delete row that are checked with a checkbox.
function deleterows() {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.showRows(1, sheet.getMaxRows());
var values = sheet.getRange('K1:K50').getValues();
values.forEach( function (r, i) {
Logger.log(r);
if (r[0])
sheet.deleteRows(i+1);
});
}
But it does not work properly - when I select multiple rows with the checkboxes - it deletes part of selected and part of the rows that follow selection screenshot
I am new the JavaScripts so can someone help me please