Em có code script sau nhưng không lỗi do đâu tại dòng else if
function onEdit (e) {
var box = SpreadsheetApp.getActiveSheet().getRange(1, 2).getValue();
var box2 = SpreadsheetApp.getActiveSheet().getRange(1, 4).getValue();
if(box == "TRUE")
var as = e.source.getActiveSheet();
const cell = e.range.getA1Notation();
const cell_checks = ['B1'];
//{cell_checks.filter(val=>val=cell1).forEach(c=>as.getRange(c).uncheck())}
var source = SpreadsheetApp.getActiveSpreadsheet();
var sheet = source.getSheetByName('KEEP');
var value = SpreadsheetApp.getActiveSheet().getRange(2, 1).getValue();
for(i=1;i<=31;i++)
{
sheet.copyTo(source).setName(""+ i);
source.getSheetByName(""+ i).getRange('A2').setValue(i);
}
else if( box2 =="TRUE")
// var copysh=deleteAllSheets()
var as = e.source.getActiveSheet();
const cell1 = e.range.getA1Notation();
const cell_checks2 = ['D1'];
// {cell_checks2.filter(val=>val=cell).forEach(c=>as.getRange(c).uncheck())}
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getSheetByName('KEEP');
for (i = 0; i < sheets.length; i++) {
switch(sheets.getSheetName()) {
case "KEEP":
break;
default:
ss.deleteSheet(sheets);
}
}
}
function onEdit (e) {
var box = SpreadsheetApp.getActiveSheet().getRange(1, 2).getValue();
var box2 = SpreadsheetApp.getActiveSheet().getRange(1, 4).getValue();
if(box == "TRUE")
var as = e.source.getActiveSheet();
const cell = e.range.getA1Notation();
const cell_checks = ['B1'];
//{cell_checks.filter(val=>val=cell1).forEach(c=>as.getRange(c).uncheck())}
var source = SpreadsheetApp.getActiveSpreadsheet();
var sheet = source.getSheetByName('KEEP');
var value = SpreadsheetApp.getActiveSheet().getRange(2, 1).getValue();
for(i=1;i<=31;i++)
{
sheet.copyTo(source).setName(""+ i);
source.getSheetByName(""+ i).getRange('A2').setValue(i);
}
else if( box2 =="TRUE")
// var copysh=deleteAllSheets()
var as = e.source.getActiveSheet();
const cell1 = e.range.getA1Notation();
const cell_checks2 = ['D1'];
// {cell_checks2.filter(val=>val=cell).forEach(c=>as.getRange(c).uncheck())}
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getSheetByName('KEEP');
for (i = 0; i < sheets.length; i++) {
switch(sheets.getSheetName()) {
case "KEEP":
break;
default:
ss.deleteSheet(sheets);
}
}
}