Profile cover photo
Profile photo
Pet Natividad
92 followers
92 followers
About
Posts

This is a script Ive used in moving a row of data to another sheet based on column #10. I was able to make the script below work but its only runs when the row is being edited/updated/created. I have close to 3K rows I want the script to run from the top without having to edit each row for the script to be triggered. Is there a way to trigger this script on a open existing sheet, not having to edit it. I've tried onOpen but doesn't do anything.

Thanks





function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getActiveSheet();
var r = ss.getActiveRange();
if(s.getName() == "Main" && r.getColumn() == 10 && r.getValue().toLowerCase() == "no")


{

var row = r.getRow();
var numColumns = s.getLastColumn();

var targetSheet = ss.getSheetByName("Bad");

if(targetSheet.getLastRow() == targetSheet.getMaxRows()) {


targetSheet.insertRowsAfter(targetSheet.getLastRow(), 20); //inserts 20 rows after last used row
}
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).moveTo(target);
s.deleteRow(row);
}
}

Post has attachment
Add a comment...

Post has attachment
Add a comment...

Post has attachment

Post has attachment
Add a comment...

Post has attachment

Post has attachment
Add a comment...

Post has attachment
Add a comment...

Post has attachment

Post has attachment
Wait while more posts are being loaded