Hello, I'm using the following code to generate a TOC. Is there a way to make it exclude any hidden sheets?
Many thanks.
Sub CreateLinksToAllSheets()
Dim sh As Worksheet
Dim cell As Range
Range("C7:C40").Select
Selection.ClearContents
Range("C7").Select
For Each sh In ActiveWorkbook.Worksheets
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
Range("C7:C40").Select
With Selection.Font
.Size = 13
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("o4").Select
End Sub
Bookmarks