Hello Excel Wizards
I'm trying to produce an index page for my Excel Workbook, with a hyperlink for each sheet, along with several cells (the same cell refernce on each sheet) also copied to the Index page to form a detailed Table of Contents.
I have the following to provide me with a list of Hyperlinked sheet names, but can't work out how to add the other cells to form a table:
Sub GenIndexSheet()
Dim Ws As Worksheet
Dim i As Long: i = 1
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'Create an Index Sheet. If already existing, clear it.
On Error Resume Next
Set Ws = Worksheets("Index")
If Err.Number = 0 Then
Worksheets("Index").ClearContents
Else
On Error GoTo 0
Worksheets.Add(Before:=Worksheets(1)).Name = "Index"
End If
Worksheets("Index").Activate
Range("A1") = "Index"
Range("A1").Font.Bold = True
Range("A1").Font.Size = 20
For Each Ws In Worksheets
If Ws.Name <> "Index" Then
i = i + 1
Ws.Hyperlinks.Add Anchor:=Cells(i, 1), Address:="", SubAddress:="'" & Ws.Name & "'!A1", TextToDisplay:=Ws.Name
End If
Next Ws
Worksheets("Index").Columns(1).AutoFit
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
I'd like the table to look something like this:
Index
Sheet 1 Cell B1 Cell A2
Sheet 2 Cell B1 Cell A2
Sheet 3 Cell B1 Cell A2
Many thanks in advance