问题
I'm trying to move some rows from one spreadsheet to another based on the column A 'Timestamp'. So if the Timestamp value is more than 90 days ago from today, then the row should be deleted from spreadsheet 'archive' and appended to spreadsheet 'archive archive'. I'm struggling with the coding. Here's what I have so far.
function testArchive() {
var moveFrom = SpreadsheetApp.openById('###').getSheetByName('archive')
var moveRows = SpreadsheetApp.openById('###').getSheetByName('archive archive')
var col = 1;
var valueToWatch = Date()-90;
var moveFromLastRow = moveFrom.getLastRow();
var moveRowsLastRow = moveRows.getLastRow();
for(var row=moveFromLastRow;row>1;row--){
var values = moveFrom.getRange('A2:Y').getValues();
if (col[row] < valueToWatch){
moveRows.appendRow(values[row]);
}
}
来源:https://stackoverflow.com/questions/65161488/how-to-move-rows-based-on-column-value-on-google-sheets