this script was working before on my Google Sheet, then all of a sudden, it stopped working. I notice that the first argument (if) is working, but all the codes after that is not working. Any ideas?
function onEdit(event) { // assumes source data in sheet named Sheet1 // target sheet of move to named Sheet2 // test column with yes is col 7 or G var ss = SpreadsheetApp.getActiveSpreadsheet(); var s = event.source.getActiveSheet(); var r = event.source.getActiveRange(); if(s.getName() == "Under Contract Response Form" && r.getColumn() == 7 && (r.getValue() == "Closed" || r.getValue() == "Expired" || r.getValue() == "Cancelled")) { var row = r.getRow(); var numColumns = s.getLastColumn(); var targetSheet = ss.getSheetByName("Closed/Expired & Cancelled"); var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1); s.getRange(row, 1, 1, numColumns).copyTo(target); s.deleteRow(row); } else if(s.getName() == "Listing Response Form" && r.getColumn() == 7 && r.getValue() == "Pending" ) { var row = r.getRow(); var numColumns = s.getLastColumn(); var targetSheet = ss.getSheetByName("Under Contract Response Form"); var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1); s.getRange(row, 1, 1, numColumns).copyTo(target); s.deleteRow(row); } else if(s.getName() == "Listing Response Form" && r.getColumn() == 7 && r.getValue() == "Cancelled" ) { var row = r.getRow(); var numColumns = s.getLastColumn(); var targetSheet = ss.getSheetByName("Closed/Expired & Cancelled"); var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1); s.getRange(row, 1, 1, numColumns).copyTo(target); s.deleteRow(row); } else if(s.getName() == "Under Contract Response Form" && r.getColumn() == 7 && (r.getValue() == "Pre-list" || r.getValue() == "Withheld" || r.getValue() == "Coming Soon" || r.getValue() == "Active")) { var row = r.getRow(); var numColumns = s.getLastColumn(); var targetSheet = ss.getSheetByName("Listing Response Form"); var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1); s.getRange(row, 1, 1, numColumns).copyTo(target); s.deleteRow(row); } else if(s.getName() == "Closed/Expired & Cancelled" && r.getColumn() == 7 && r.getValue() == "Pending" ) { var row = r.getRow(); var numColumns = s.getLastColumn(); var targetSheet = ss.getSheetByName("Under Contract Response Form"); var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1); s.getRange(row, 1, 1, numColumns).copyTo(target); s.deleteRow(row); } }
https://stackoverflow.com/questions/67386806/else-if-google-script May 04, 2021 at 10:31PM
没有评论:
发表评论