[英]Google Sheets: Move a row of data to another sheet based on cell value
[英]Google Sheets Copying and Pasting from one sheet to another based on cell value
我正在使用我发现正在研究我的问题的代码。 我已经在下面发布了。 我遇到的问题是,退货的日期自然会随着一周的进行而改变。 如果在第8列中输入了“返回(日期)”的任意组合,我将如何更改代码以复制和粘贴该行,对此我很困惑
function onEdit() {
// moves a row from a sheet to another when a magic value is entered in a column
// adjust the following variables to fit your needs
// see https://productforums.google.com/d/topic/docs/ehoCZjFPBao/discussion
var sheetNameToWatch = "Checked Out";
var columnNumberToWatch = 8; // column A = 1, B = 2, etc.
var valueToWatch = "Returned 1/1";
var sheetNameToMoveTheRowTo = "Returned";
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSheet();
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, 1);
sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).moveTo(targetRange);
sheet.deleteRow(range.getRow());
}
}
有一个名为ISDATE()的Google表格公式,您可以添加一个帮助程序列来检查输入日期是否有效。 然后只需检查此单元格的返回值为TRUE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.