我有一个正在运行的脚本,然后神奇地停止了运行。我一直在寻找可能导致问题的时间,但运气为零。有什么建议吗?如果特定单元格上有一个方框打勾,则脚本假定将一行从一张纸移动到另一张纸。然后,如果未选中该框,则将其发送回另一张纸。
我讨厌在这里要求这种东西...但是我真的很受限制,没有人能够提供很多帮助。我知道你们都不是代码编辑者,还有很多鱼可以炒,但是任何帮助将不胜感激……希望其他人可以使用此:)。
function InvoiceArchive() {
var Accounts = "Accounts";
var Emailed = "Emailed";
var Paid = "Paid";
var Suspended = "Suspended";
var Closed = "Closed";
var triggerTrue = true;
var triggerFalse = false;
var accountEmailed = 14;
var accountPaid = 15;
var accountSuspended = 16;
var accountClosed = 17;
var undoArchive = "Emailed";
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getActiveCell();
//Archiving emailed invoices
if (sheet.getName() == Accounts && range.getColumn() == accountEmailed && range.getValue() == triggerTrue) {
var targetSheetE = ss.getSheetByName(Emailed);
var targetRangeE = targetSheetE.getRange(targetSheetE.getLastRow() + 1, 1);
sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).copyTo(targetRangeE);
}
///
//Archiving paid invoices
if (sheet.getName() == Emailed && range.getColumn() == accountPaid && range.getValue() == triggerTrue) {
var targetSheetP = ss.getSheetByName(Paid);
var targetRangeP = targetSheetP.getRange(targetSheetP.getLastRow() + 1, 1);
sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).moveTo(targetRangeP);
}
//Undo paid archiving
if (sheet.getName() == Paid && range.getColumn() == accountPaid && range.getValue() == triggerFalse) {
var targetSheetU = ss.getSheetByName(undoArchive);
var targetRangeU = targetSheetU.getRange(targetSheetU.getLastRow() + 1, 1);
sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).moveTo(targetRangeU);
sheet.deleteRow(range.getRow());
}
///
//Archiving suspended invoices
if (sheet.getName() == Emailed && range.getColumn() == accountSuspended && range.getValue() == triggerTrue) {
var targetSheetS = ss.getSheetByName(Suspended);
var targetRangeS = targetSheetS.getRange(targetSheetS.getLastRow() + 1, 1);
sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).moveTo(targetRangeS);
}
//Undo suspended archiving
if (sheet.getName() == Suspended && range.getColumn() == accountSuspended && range.getValue() == triggerFalse) {
var targetSheetU = ss.getSheetByName(undoArchive);
var targetRangeU = targetSheetU.getRange(targetSheetU.getLastRow() + 1, 1);
sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).moveTo(targetRangeU);
sheet.deleteRow(range.getRow());
}
//Moving account to closed
if (sheet.getName() == Suspended && range.getColumn() == accountClosed && range.getValue() == triggerTrue) {
var targetSheetC = ss.getSheetByName(archiveClosed);
var targetRangeC = targetSheetC.getRange(targetSheetC.getLastRow() + 1, 1);
sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).moveTo(targetRangeC);
sheet.deleteRow(range.getRow());
}
///
//Archiving closed invoices
if (sheet.getName() == Emailed && range.getColumn() == accountClosed && range.getValue() == triggerTrue) {
var targetSheetC = ss.getSheetByName(archiveClosed);
var targetRangeC = targetSheetC.getRange(targetSheetC.getLastRow() + 1, 1);
sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).moveTo(targetRangeC);
}
//Undo closed archiving
if (sheet.getName() == Closed && range.getColumn() == accountClosed && range.getValue() == triggerFalse) {
var targetSheetU = ss.getSheetByName(undoArchive);
var targetRangeU = targetSheetU.getRange(targetSheetU.getLastRow() + 1, 1);
sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).moveTo(targetRangeU);
sheet.deleteRow(range.getRow());
}
}