Saltar al contenido principal

¿Cómo obtener una lista de nombres de hojas en las hojas de Google?

En este artículo, presentaré algunos métodos para obtener el nombre del nombre de la hoja actual o una lista de los nombres de las hojas en las hojas de Google.

Obtenga el nombre de la hoja actual en las hojas de Goolge con script

Obtenga una lista de nombres de hojas en hojas de Google con script


Obtenga el nombre de la hoja actual en las hojas de Goolge con script

Para obtener el nombre de la hoja actual en las hojas de Google, el siguiente script simple puede ayudarlo sin ingresar el nombre manualmente, haga lo siguiente:

1. Hacer clic Herramientas > Editor de scripts, ver captura de pantalla:

doc obtener el nombre de la hoja 1

2. En la ventana del proyecto abierta, copie y pegue el siguiente código de secuencia de comandos en el espacio en blanco Código ventana, ver captura de pantalla:

function sheetName() {
  return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
}

doc obtener el nombre de la hoja 2

3. Luego, guarde la ventana de código y vuelva a la hoja de la que desea obtener su nombre, luego ingrese esta fórmula: =sheetname() en una celda y presione Participar clave, el nombre de la hoja se mostrará a la vez, vea la captura de pantalla:

doc obtener el nombre de la hoja 3


Obtenga una lista de nombres de hojas en hojas de Google con script

Si desea obtener todos los nombres de las hojas en las hojas de Google, aquí hay otro script que puede hacerle un favor, haga lo siguiente:

1. Hacer clic Herramientas > Guión editor para ir a la ventana del proyecto, y luego copie y pegue el siguiente código de secuencia de comandos en el espacio en blanco Código ventana, ver captura de pantalla:

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  
}

doc obtener el nombre de la hoja 4

2. Luego guarde la ventana de código y regrese a la hoja de la que desea obtener todos los nombres de hoja, luego ingrese esta fórmula: =sheetnames() en una celda y presione Participar , todos los nombres de las hojas en las hojas de Google se enumerarán como se muestra en la siguiente captura de pantalla:

doc obtener el nombre de la hoja 5


Enumere todos los nombres de las hojas y navegue entre ellos utilizando hipervínculos o botones en el libro de Excel:

Con Kutools for Excel's Crear lista de nombres de hojas utilidad, puede enumerar rápidamente todos los nombres de las hojas de trabajo en una nueva hoja con hipervínculos o botones de macro, luego puede navegar entre ellos según sus necesidades.

Kutools for Excel: con más de 300 prácticos complementos de Excel, prueba gratuita y sin límite en 30 días. ¡Descarga y prueba gratis ahora!

Las mejores herramientas de productividad de oficina

🤖 Asistente de IA de Kutools: Revolucionar el análisis de datos basado en: Ejecución inteligente   |  Generar codigo  |  Crear fórmulas personalizadas  |  Analizar datos y generar gráficos  |  Invocar funciones de Kutools...
Características populares: Buscar, resaltar o identificar duplicados   |  Eliminar filas en blanco   |  Combine columnas o celdas sin perder datos   |   Ronda sin fórmula ...
Super búsqueda: Búsqueda virtual de criterios múltiples    Búsqueda V de valores múltiples  |   VLookup en varias hojas   |   Búsqueda difusa ....
Lista desplegable avanzada: Crear rápidamente una lista desplegable   |  Lista desplegable dependiente   |  Lista desplegable de selección múltiple ....
Administrador de columnas: Agregar un número específico de columnas  |  Mover columnas  |  Toggle Estado de visibilidad de columnas ocultas  |  Comparar rangos y columnas ...
Características destacadas: Enfoque de cuadrícula   |  Vista de diseño   |   Gran barra de fórmulas    Administrador de hojas y libros de trabajo   |  Biblioteca de Recursos (Texto automático)   |  Selector de fechas   |  Combinar hojas de trabajo   |  Cifrar/descifrar celdas    Enviar correos electrónicos por lista   |  Súper filtro   |   Filtro especial (filtro negrita/cursiva/tachado...) ...
Los 15 mejores conjuntos de herramientas12 Texto Herramientas (Añadir texto, Quitar caracteres, ...)   |   50+ Tabla Tipos (Diagrama de Gantt, ...)   |   40+ Práctico Fórmulas (Calcular la edad según el cumpleaños, ...)   |   19 Inserción Herramientas (Insertar código QR, Insertar imagen desde la ruta, ...)   |   12 Conversión Herramientas (Números a palabras, Conversión de Moneda, ...)   |   7 Fusionar y dividir Herramientas (Filas combinadas avanzadas, Células partidas, ...)   |   ... y más

Mejore sus habilidades de Excel con Kutools for Excel y experimente la eficiencia como nunca antes. Kutools for Excel ofrece más de 300 funciones avanzadas para aumentar la productividad y ahorrar tiempo.  Haga clic aquí para obtener la función que más necesita...

Descripción


Office Tab lleva la interfaz con pestañas a Office y hace que su trabajo sea mucho más fácil

  • Habilite la edición y lectura con pestañas en Word, Excel, PowerPoint, Publisher, Access, Visio y Project.
  • Abra y cree varios documentos en nuevas pestañas de la misma ventana, en lugar de en nuevas ventanas.
  • ¡Aumenta su productividad en un 50% y reduce cientos de clics del mouse todos los días!
Comments (21)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Thanks :)))
This comment was minimized by the moderator on the site
This script in Google Sheets works great! However, sheetnames() doesn't seem to update when new sheets are added or sheets are renamed. Is there a way to make it refresh?
This comment was minimized by the moderator on the site
why is it not working for me?i have copied the scripts and they seem so run with no errors, but when i go to google sheets, it dosent show the function "sheetsname"
This comment was minimized by the moderator on the site
Save the script and run
This comment was minimized by the moderator on the site
How to export all sheet names in open excel file to Google Sheet? Thank you
This comment was minimized by the moderator on the site
How to export all sheet names in open excel file to Google Sheet?
This comment was minimized by the moderator on the site
works for me! Thanks!!!
This comment was minimized by the moderator on the site
TypeError: Cannot read property 'getSheets' of null (riadok 3, súbor Kód)
This comment was minimized by the moderator on the site
Sorry.I did something wrong.It is already working fine.
This comment was minimized by the moderator on the site
Hey, may i know what is your mistake? i have the same error
This comment was minimized by the moderator on the site
Hi.
Of course You can.
I created a script using the Google Script Manager (script.google.com) and thought it would work automatically on all sheets in my google drive, but that wasn't true.Probably a script created throught Google Script Manager, not throught sheet, is not linked to a sheet.I had to create a script via menu in the top bar in the open Google Sheets "Tools / Script Editor" and the function I created works only in that given sheet.Please write if this solved your problem.
:)
This comment was minimized by the moderator on the site
Hello,


Ive registered an account just to say, ive found a way to automatically update this function, its a cheat really.



In cell C!, ive put a checkbox.

At my header of sheet names, I put this code.



=if(C1=true,sheetnames(),)


Then, when we edit a tab name or create a new one, we uncheck the box and check it again and it is done, not perfect, but better than deleting the cell and re-pasting.


Thank you


Charlie.

EDIT , i tried inserting picture, but it seems to disappear.
This comment was minimized by the moderator on the site
For everyone wondering how to get the sheet index to update automatically, you need to be able to call the function and then Re-enter the formula into where you want the index to be kept.
In my case I have a dedicated Index Sheet, and after most of my functions I call 'sheetnames()' and then just Re-enter the formula in the specific cell.
This comment was minimized by the moderator on the site
sheetnames();
ss.getSheetByName('Index').getRange('A1').setFormula('=sheetnames()');
This comment was minimized by the moderator on the site
What's ss?
This comment was minimized by the moderator on the site
Hi Carlos,

var ss = SpreadsheetApp.getActive();

Hope that helps.
This comment was minimized by the moderator on the site
me pueden ayudar para crear una macro en GAS que abra una nueva hoja (sheet), luego la renombre y luego se puede escribir dentro de esta hoja nueva?
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations