hacer lista de los nombre de las hojas de un documento en excel

15/05/2005 - 22:26 por BARRIOS | Informe spam
Tengo un documento en excel de 200 hojas, cada hoja tiene un nombre. Pero
necesito crear una lista (tipo índice), con el nombre de cada hoja. ¿Hay
alguna opción que me ayude a no escribir cada nombre de hoja?
 

Leer las respuestas

#1 KL
15/05/2005 - 23:17 | Informe spam
Hola Barrios,

Prueba el siguiente codigo. Este codigo lo puedes ejecutar desde cualquier
modulo y creara un indice en la primera hoja del libro activo.

Saludos,
KL

'-Inicio Codigo--
Sub ListarHojas()
Dim i As Integer
Dim hIndice As Worksheet
Dim h
Dim hTipo As String
Dim hVisible As String
Dim hProtegida As String

Set hIndice = ActiveWorkbook.Worksheets(1)

With hIndice
.Cells(1, 1) = "Nombre"
.Cells(1, 2) = "Tipo"
.Cells(1, 3) = "Visible"
.Cells(1, 4) = "Protegida"
.Range("1:1").Font.Bold = True
i = 2
For Each h In ActiveWorkbook.Sheets
If h.Type = 3 Then
hTipo = "Grafico"
Else
hTipo = "Hoja de calculo"
End If
If h.Visible = xlSheetVisible Then
hVisible = "Verdadero"
Else
hVisible = "Falso"
End If
If h.ProtectContents Then
hProtegida = "Verdadero"
Else
hProtegida = "Falso"
End If
.Cells(i, 1) = h.Name
.Cells(i, 2) = hTipo
.Cells(i, 3) = hVisible
.Cells(i, 4) = hProtegida
i = i + 1
Next h
End With
End Sub
'-Fin Codigo--

Preguntas similares