错误“缺少;”我无法解决

时间:2018-07-17 15:22:01

标签: google-apps-script syntax-error

function goToRecordInClasses() {
  var spreadsheet = SpreadsheetApp.getActive();
  var activeSheet = spreadsheet.getActiveSheet().getName();
  if (activeSheet == "Students"){
    var sheet = spreadsheet.getSheetByName("Students");
    var sourceSheet = spreadsheet.getSheetByName('Classes');
    var sheetRow = sheet.getActiveCell().getRow();
    var recordRefNumber = sheet.getRange("B"+sheetRow).getValue();
    If (recordRefNumber > 0){ //This is the line that is highlighted with the error message.
      var searchRange = sourceSheet.getRange("A1:A" + sourceSheet.getLastRow());
      var values = searchRange.getValues();
      var recordRowIndex = [];
      for (var y = 0; y < values.length; y++) {
        if(values[y][0] == recordRefNumber){
          recordRowIndex.push(y + 1);
        };
      };
      sourceSheet.showRows(1,sourceSheet.getMaxRows());
      var range = sourceSheet.getRange("A"+recordRowIndex+":M"+recordRowIndex);
      range.activate();
    }
    else{
      var ui = SpreadsheetApp.getUi();
      ui.alert("The selected record has no reference number.").OK;
    };
  }
  else{
    var ui = SpreadsheetApp.getUi();
    ui.alert("First select a cell in STUDENTS sheet").OK;
  };
};

在上面的代码中,我遇到以下错误消息:

  

缺少;声明前。 (第75行,文件为“宏”)

我还用错误消息附上了代码的照片。

我已在代码行中添加了一条引发错误的注释。

The photo of the code with error message

2 个答案:

答案 0 :(得分:2)

If以大写字母“ I”表示,我想您要使用小写字母。

答案 1 :(得分:2)

第75行上的小写字母if