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

193
Views
Copies of Hidden Sheets in Apps Script

I have this fragment of code that make a copy of each Sheet in the document. I don't know if it makes copies of Hidden Sheets, the _temp copy of the hidden sheets do not appear in the interface but i suppose they are also hidden. In case it does the copies, how could I modify the code to not copy hidden sheets? I have a lot of hidden sh in my document and it could save time and avoid crashes.

var ss = SpreadsheetApp.openById(spreadsheetId);
var tempSheets = ss.getSheets().map(function(sheet) {
  var dstSheet = sheet.copyTo(ss).setName(sheet.getSheetName() + "_temp");
  var src = dstSheet.getDataRange();
  src.copyTo(src, {contentsOnly: true});
  return dstSheet;
});

Thanks

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

This should work:

var ss = SpreadsheetApp.openById(spreadsheetId);
var tempSheets = ss.getSheets().filter(sheet => !.isSheetHidden()).map(function(sheet) {
  var dstSheet = sheet.copyTo(ss).setName(sheet.getSheetName() + "_temp");
  var src = dstSheet.getDataRange();
  src.copyTo(src, {contentsOnly: true});
  return dstSheet;
});

sheet.isSheetHidden() will return true if the sheet is hidden, and false otherwise. We first filter the list to non-hidden sheets, and then only copy the rest of the sheets.

about 4 years ago · Juan Pablo Isaza Report

0

Copy unhidden sheets

function copyunhidden() {
  const ss = SpreadsheetApp.openById("id");
  ss.getSheets().filter(sh => !sh.isSheetHidden()).forEach(s => {
    s.copyTo(ss).setName(s.getName() + "_temp")
  });
}
about 4 years ago · Juan Pablo Isaza 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!