Hey everyone,
I've tried a few different things but can't seem to figure out how to add the tab colour from the worksheet to the cell within the Table of Contents I created for myself. Below is what I have so far, but something isn't working:
I'm probably not on the right path, but hoping someone can point me in the right direction. Thanks.
I've tried a few different things but can't seem to figure out how to add the tab colour from the worksheet to the cell within the Table of Contents I created for myself. Below is what I have so far, but something isn't working:
Code:
Sub HyperlinkTOC()
Dim i As Long
Dim LinkCell As Variant
On Error Resume Next
Application.DisplayAlerts = False
Application.DisplayAlerts = True
LinkCell = InputBox("Which would you like to be the linked active cell?")
On Error GoTo 0
'ThisWorkbook.Sheets.Add Before:=ThisWorkbook.Worksheets(1)
'ActiveSheet.Name = "Table of Content"
For i = 1 To Sheets.Count
With ActiveSheet
.Hyperlinks.Add _
Anchor:=ActiveSheet.Cells(ActiveCell.Row - 1 + i, ActiveCell.Column), _
Address:="", _
SubAddress:="'" & Sheets(i).Name & "'!" & LinkCell, _
ScreenTip:=Sheets(i).Name, _
TextToDisplay:=Sheets(i).Name
End With
Worksheets(i).Tab.ColorIndex = ActiveCell.Interior.ColorIndex
Next i
ActiveCell.Delete
End Sub
I'm probably not on the right path, but hoping someone can point me in the right direction. Thanks.