How to move rows based on column value on google sheets? [duplicate]

…衆ロ難τιáo~ 提交于 2021-01-20 12:53:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!