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行,文件为“宏”)
我还用错误消息附上了代码的照片。
我已在代码行中添加了一条引发错误的注释。
答案 0 :(得分:2)
If
以大写字母“ I”表示,我想您要使用小写字母。
答案 1 :(得分:2)
第75行上的小写字母if