I came across this script that moves rows from one tab to another tab depending on the values from a specific column. It's working perfectly but this can only work on a single tab. Is it possible for this script to run on multiple tabs and move records to a specific tab only?
For example, here is the list of tabs to be watched:
- AAA
- BBB
- CCC
- DDD
- EEE
- etc...
When the value in Column N (contains =IF formula that determines the value depending on the condition set) is changed to Completed, the script will automatically copy the row to the DONE sheet and then delete the row.
I am not sure if onEdit() will work.
Note: All of the tabs are identical.
Here is the script I found here in the forum:
function onEdit() {
var app = SpreadsheetApp;
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheetNameToWatch = ss.getSheetByName("Current")
var columnNumberToWatch = 8;
var valueToWatch = "DONE";
var sheetNameToMoveTheRowTo = "OLD";
//var ss = SpreadsheetApp.getActiveSpreadsheet();//this has already been declared
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getActiveCell();
if (sheet.getName() == "Current" && range.getColumn() == 8 && range
.getValue() == "DONE") {
var targetSheet = ss.getSheetByName("OLD");
var targetRange = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).moveTo(
targetRange);
sheet.deleteRow(range.getRow());
}
}
onEditis triggered when any sheet (tab) is edited. Please show what you tried to adapt the script to your needs. - Rubénsheet.getName() == "Current" &&- Rubén