Option Explicit
Sub TOC_Basic()
Dim sh As Worksheet
Dim cell As Range
Dim i As Long
'Delte the existing data from the cells before inserting new hyperlinks.
Range("B5").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("B5").Select
'Now Insert the Hyperlinks to visible sheets.
For Each sh In Sheets
With sh
If .Visible = True Then
'For Each sh In ActiveWorkbook.Worksheets <*1 - Activate this line if want to hyperlink all sheets, hidden/unhidden, and delete above three lines and delete relevant end tags.>
If ActiveSheet.Name <> sh.Name Then
ActiveCell.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"'" & sh.Name & "'" & "!A1", TextToDisplay:=sh.Name
ActiveCell.Offset(1, 0).Select
End If
'Next sh < activate this if *1 activated>
End If
End With
Next sh
Range("B5").Select
End Sub