1

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?

0

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

My goodness. Typical. Thank you!
Rather than commenting to say "thanks," you should show your appreciation by clicking the check mark to the left of this answer to mark it as "accepted." Doing so awards 15 reputation points to the author and visually shows others that the answer solved your problem. You can also click the up arrow there to vote the answer up. Doing so awards an additional 10 reputation points to the author and increments the score of the answer. The top scored answer is sorted to the top which helps other people with similar problems find it. @Benzene_OH

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.