谷歌脚本中途停止

时间:2016-02-18 00:13:51

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

以下脚本只是在将RESET输入第一个单元格时替换工作表的BG颜色。这可以工作到高400,但工作表有662行。任何想法为什么它停止做空,我确实要求转到lastRow并使用值662以相同的结果对其进行补充。

function onEdit() 
{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName('Sheet1');
  var lastRow = sheet.getLastRow();
  var lastColumn = sheet.getLastColumn();

  var resetCells = sheet.getRange("A1");
  var resetCell = resetCells.getValues();

  if (resetCell == "RESET")
  {
    sheet.getRange("A1").clearContent();

    var x;
    var y = 0;
    for (x = 1; x <= lastRow; x++)
    {
     var Location = sheet.getRange(x, 1);
     var currentCell = Location.getValues();
     var cell = ss.getActiveCell();
     var range = sheet.getRange(x, 1, 1, lastColumn);
     if (currentCell == "")
      {
        y++;
      }

     if (currentCell != "")
      {
        if (y%2 == 0)
        {
          range.setBackgroundRGB(225, 125, 75);
        }
        else
        {
          range.setBackgroundRGB(75, 125, 225);
        }
      }

    }
  }
}

0 个答案:

没有答案