Write Sheet Names in "Index" Worksheet

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

‘Write sheet names in “Index” worksheet

Private Sub Worksheet_Activate()

Dim worksheet As Worksheet


Dim xRow As Integer
Dim calcState As Long
Dim scrUpdateState As Long
Application.ScreenUpdating = False
xRow = 2
With Me
.Columns(1).ClearContents
.Cells(2, 1) = "INDEX"
.Cells(2, 1).Name = "Index"
End With
For Each worksheet In Application.Worksheets
If worksheet.Name <> Me.Name Then
xRow = xRow + 1
With worksheet
.Range("A1").Name = "Start_" & worksheet.Index
.Hyperlinks.Add anchor:=.Range("A1"), Address:="", _
SubAddress:="Index", TextToDisplay:="Back to Index"
End With
Me.Hyperlinks.Add anchor:=Me.Cells(xRow, 1), Address:="", _
SubAddress:="Start_" & worksheet.Index, TextToDisplay:=worksheet.Name
End If
Next
Application.ScreenUpdating = True
End Sub

‘Write sheet names in “Index” worksheet

Private Sub Worksheet_Activate()


'Updateby20150305
Dim xSheet As worksheet
Dim xRow As Integer
Dim calcState As Long
Dim scrUpdateState As Long
Application.ScreenUpdating = False
xRow = 2
With Me
.Columns(1).ClearContents
.Cells(2, 1) = "INDEX"
.Cells(2, 1).Name = "Index"
End With
For Each xSheet In Application.Worksheets
If xSheet.Name <> Me.Name Then
xRow = xRow + 1
With xSheet
.Range("A1").Name = "Start_" & xSheet.Index
.Hyperlinks.Add anchor:=.Range("A1"), Address:="", _
SubAddress:="Index", TextToDisplay:="Back to Index"
End With
Me.Hyperlinks.Add anchor:=Me.Cells(xRow, 1), Address:="", _
SubAddress:="Start_" & xSheet.Index, TextToDisplay:=xSheet.Name
End If
Next
Application.ScreenUpdating = True
End Sub

You might also like