Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

200
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda