向后循环遍历数据值

时间:2018-08-20 13:43:07

标签: loops google-apps-script google-sheets

我猜想我的逻辑对循环中使用的值不起作用。不太确定如何进行。谢谢。

var ss = SpreadsheetApp.getActiveSpreadsheet();

var ash = ss.getSheetByname("Master List C");
var laRow = ash.getLastRow();
var laCol = ash.getLastColumn();
var toMove = [];

var dsh = ss.getSheetByname("Non-Members");
var ldRow = dsh.getLastRow();
var ldCol = dsh.getLastColumn();

var range = ash.getRange(9, 1, laRow, laCol);
var aData = range.getValues();

for (row = aData.length; row >= 9; row--) {
   if (aData[row][6] == "No") {
     var tmp = [aData[row][0], aData[row][1], aData[row][2], aData[row][3], aData[row][4], aData[row][5], aData[row][8]];
     toMove.push(tmp);
     dsh.getRange(dsh.getLastRow() + 1, 1, toMove.length, 7).setValues(toMove);
     ash.deleteRow(row);
   }
}

0 个答案:

没有答案