Home > Enterprise >  Sheet with name as number not being returned with getSheetByName in For loop
Sheet with name as number not being returned with getSheetByName in For loop

Time:08-12

I am having trouble getting this for loop to work correctly:

for(var d = 0; d < sheetno/2; d = d   1){
 var dsheet1 = print_ss.getSheetByName(d);
 var dsheet2 = print_ss.getSheetbyName(d 100);
 print_ss.deleteSheet(dsheet1);
 print_ss.deleteSheet(dsheet2);
  
}

I have a sheet named "0" and another named "100" and so on (dependent on how many sheets are in the spreadsheet).

The script works for the first sheet (i.e. finds the sheet named "0"):

var dsheet1 = print_ss.getSheetByName(d);

But it returns a "TypeError: print_ss.getSheetbyName is not a function" for the following line:

var dsheet2 = print_ss.getSheetbyName(d 100);

What am I doing wrong?

CodePudding user response:

You have a typo. It should be getSheetByName but not getSheetbyName

  • Related