I found this question and answer which was helpful but I'm wondering how to apply the script (also pasted below) to multiple tabs within a sheet. The column (column 2) to check for an edit to trigger the line to move to the bottom is going to be the same on all sheets (Sheet1, Sheet2, Sheet3).
function onEdit(e) {
const row = e.range.getRow();
const col = e.range.getColumn();
const as = e.source.getActiveSheet();
if(as.getName() == "Sheet1" && col == 2 && row > 1 && !as.getRange(row,col).getValue()=='') {
const row_new = as.getRange(row,1,1,col);
row_new.copyTo(as.getRange(as.getLastRow() 1,1,1,col));
as.deleteRow(row);
}
}
Thanks in advance!
CodePudding user response:
Applying onEdit to multiple sheets
function onEdit(e) {
const sh = e.range.getSheet();
const shts = ['Sheet1','Sheet2','Sheet3'];
const idx = shts.indexOf(sh.getName())
if(~idx && e.range.columnStart == 2 && e.range.rowStart > 1 && e.value) {
const row_new = sh.getRange(e.range.rowStart,1,1,e.range.columnStart);
row_new.copyTo(sh.getRange(sh.getLastRow() 1,1,1,e.range.columnStart));
sh.deleteRow(e.range.rowStart);
}
}