Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:08:35+00:00 2026-06-13T12:08:35+00:00

Here is what I am doing (I copied and tried to adapt it from

  • 0

Here is what I am doing (I copied and tried to adapt it from old messages) :

1) inside a spreadsheet that have many sheets create a sheet and renamed it “TOC”

2) in “TOC”, add this formula inside A1: =SheetNames( GoogleClock() )

3) Once copied in Google Apps Script, run function “SheetNames” below

function SheetNames() { // this will create a list of all the sheets ;)
try {
  var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets()
  var out = new Array( sheets.length+1 ) ;
  out[0] = [ "Name" , "gid" ];
  for (var i = 1 ; i < sheets.length+1 ; i++ ) out[i] = [sheets[i-1].getName() , sheets[i-1].getSheetId() ];
  return out
}
catch( err ) {
  return "#ERROR!" 
}
}

4) run function “delete_only_some_sheets”

function delete_only_some_sheets() {
// CAUTION !! It will delete some sheets ! 
var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getSheetByName("TOC");
for (var i = 3; i<=5; i++){ // !!! HERE adapt the "5" number to your needs here
var tet = source.getRange(["B"]+[(i)]).getValues();

//ss.setActiveSheet(ss.getSheetId()[tet]); ///ERROR here ! ;(
   ss.deleteActiveSheet();
   //ss.deleteSheetId()[tet]; //possible ??

}
}

I keep getting the error “Cannot find method “setActiveSheet(.”” And I am blocked. ;(

Many thanks in advance 😉

EDIT :

Hello,
Thanks to “Srik”, I have found the solution ! 😉
Part 1) to 3) are the same. Part 4) becomes :

4) run function “delete_only_some_sheets”

function delete_only_some_sheets() {
// CAUTION !! IT will delete some sheets ! 
var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getSheetByName("TOC");
for (var i = 3; i<=5; i++){ // !!! HERE adapt the "5" number to your needs here
var tet = source.getRange(["A"]+[(i)]).getValues();

ss.setActiveSheet(ss.getSheetByName(tet));
ss.deleteActiveSheet();

}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:08:35+00:00Added an answer on June 13, 2026 at 12:08 pm

    First, there is no getSheetId() method. I assume you are referring to the getSheets() method here which returns an array of Sheet objects.

    Second, setActiveSheet() takes a Sheet object as an argument. Using getSheets() method, you can simply do it as follows

    ss.setActiveSheet(ss.getSheets()[i]);
    

    There is no need to read the TOC sheet, fetch the id etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What am I doing wrong here? private void SendMail(string from, string body) { string
There is a ProcDump tutorial here: http://drdobbs.com/blogs/parallel/229300328 I have an application that crashes, so
I've almost tried everything and even exactly copied the example: [in here][1] However I
I have a list of files that must be copied to a new directory.
Okay, I'm not doing anything fancy here, but it's driving me crazy that I
I have now tried for hours getting xDebug (2.0.5 compiled from source) to work
I'm doing a project on an iPhone. Here I have to send a POST
I am not sure what I should be doing here. Should I be hardcoding
Can you explain for me what the typedef here is doing and what the
I'm trying to achieve what this guy here is doing, only in PHP or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.