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

198
Views
Google Script to Create Tab Names Based on List

I am very new to Google Apps Scripts, but am working to create a spreadsheet function that will create new tabs based a list of names (in cells C6:C). Some of the cells may not have values in them, so would like to exclude these cells from creating new tabs.

The function works as planned, but after running the script, the new tabs are named with a (1), (2), (3),... etc. after the name that is in the list. For example if the first name in the list is "First Tab", the new tab gets named "First Tab (1)" after my current script is run.

I'm not sure as to what would be causing the numbers in the tab names, so any help would be greatly appreciated!

For reference, Cell B4 contains a count of the number of names in the List that the new Tabs should be created from

'''

function createProjectTabs() {

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = ss.getRange("C6:C");
var values = range.getValues().filter(String);
var total = ss.getRange('B4').getValue();

for(var k=0; k < total; k++){
  try{
    
    var tabName = range[k][0];
      ss.insertSheet(tabName);}
  catch(err){
    
    tabName = values [k][0]+ " " + k;
    ss.insertSheet(tabName);}
  }
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

function createNonDuplicateProjectTabs() {
  var ss = SpreadsheetApp.getActive();
  const shts = ss.getSheets().map(s => s.getName());
  var sh = ss.getSheets()[0];
  var vs = ss.getRange(6,3,sh.getLastRow()-5,1).getValues().flat();
  vs.forEach(n => {
    if(!~shts.indexOf(n)) {
      ss.insertSheet(n)
    }
  });
}
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!