我需要一些关于此脚本的帮助
function issueComplete() {
var sheetNameToWatch = "ISSUES";
var columnNumberToWatch = 11;
var valueToWatch = "YES";
var sheetNameToMoveTheRowTo = "ARCHIVE";
var finalSheet = "ISSUE_ARCHIVE";
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSheet();
var sheet2 = ss.getSheetByName(finalSheet);
var range = sheet.getActiveCell();
if (sheet.getName() == sheetNameToWatch && range.getColumn() == columnNumberToWatch && range.getValue() == valueToWatch) {
var targetSheet = ss.getSheetByName(sheetNameToMoveTheRowTo);
var targetRange = targetSheet.getRange(targetSheet.getLastRow() + 1, 2);
sheet2.getRange(range.getRow(), 2, 1, sheet.getLastColumn()).moveTo(targetRange);
sheet.deleteRow(range.getRow());
sheet2.deleteRow(range.getRow());
var lastrow = sheet.getLastRow();
sheet.insertRows(lastrow, 1);
}
}
现在更多关于我需要帮助的内容,
我总共使用3张
Sheet1 (Sheet to be edited)
Sheet2 (With the information)
Sheet3(目标 - 与Sheet2完全相同的布局)
用户将使用工作表1,当他们从J列的下拉菜单中选择“是”时,它将在工作表2上将该行值发送到工作表3,然后删除工作表1和工作表1上的行。 sheet2并添加新的替换行。
我有一个与上面代码类似的版本,如果我希望将活动工作表中的信息移动到另一个,但是当它涉及3时,它的效果很好!
对此的任何帮助将不胜感激。
答案 0 :(得分:0)
好的,我想我找到了一个解决方案,但如果有人认为无论如何都可以改进,请告诉我!
function issueComplete() {
Utilities.sleep(200);
var sheetNameToWatch = "ISSUES";
var columnNumberToWatch = 10;
var valueToWatch = "COMPLETED";
var sheetNameToMoveTheRowTo = "ARCHIVE";
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getActiveCell(); // what cell changed?
if (sheet.getName() == sheetNameToWatch && range.getColumn() == columnNumberToWatch && range.getValue() == valueToWatch) {
var targetSheet = ss.getSheetByName(sheetNameToMoveTheRowTo);
var targetRange = targetSheet.getRange(targetSheet.getLastRow() + 1, 2);
var infoSheet = ss.getSheetByName("ISSUE_ARCHIVE")
infoSheet.getRange(range.getRow(), 2, 1, sheet.getLastColumn()).moveTo(targetRange);
var formulas = range.getFormulas();
range.clearContent();
range.setFormulas(formulas);
infoSheet.deleteRow(range.getRow());
}
}