Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
Exclude sheets from list Of Sheet Names With Script

I have found this piece of script that can create a list of all the sheet names in a Google sheet using app script.

But i would like to exclude some of the sheets from the list. For example if i don't want "Sheet 2" and "Sheet 4" in the list

function sheetnames() { 
  var out = new Array()
  var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
  for (var i=0 ; i<sheets.length ; i++) out.push( [ sheets[i].getName() ] )
  return out  
}
about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

function sheetNames() {

  const exclude = [`Sheet1`, `Sheet2`]

  return SpreadsheetApp.getActiveSpreadsheet()
                       .getSheets()
                       .map(sheet => sheet.getName())
                       .filter(sheet => !exclude.includes(sheet))

}
about 4 years ago · Santiago Gelvez Report

0

Excluded selected sheets

function sheetnames() { 
  var out = new Array()
  var exA = ["Sheet1","Sheet2","Sheet3"];
  var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets().filter(sh => !~exA.indexOf(sh.getName()));
  for (var i=0 ; i<sheets.length ; i++) out.push( [ sheets[i].getName() ] )
  return out  
}
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!