Table of contents formula to return hyperlinks to sheets

Penn01

New Member
Joined
Jul 11, 2014
Messages
4
The following formula lists all worksheets in my workbook:

=IF(COUNTA(Sheets)>=ROW($A4),INDEX(Sheets,ROW($A4)),"")

[the (Sheets) reference is a named range of worksheets with the formula =SUBSTITUTE(GET.WORKBOOK(1),"["&GET.WORKBOOK(16)&"]","")]

I want this to also return a hyperlink to each worksheet - I have tried the below but this returns the message "cannot open the specified file" when the hyperlink is clicked. Can anyone help out on what I'm doing wrong?

=HYPERLINK(COUNTA(Sheets)>=ROW($A3),INDEX(Sheets, ROW($A3)))

Many thanks,
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
... I'm not too sure about your worksheet formulas.

You could, instead, use VBA to build a list of worksheets containing hyperlinks. Try this code:

Code:
Sub BuildContents()

    Dim Sht As Worksheet
    Dim Rng As Range
    Dim Cnt As Integer
    
    'Set cell for start of contents
    Set Rng = ThisWorkbook.Worksheets("Contents").Range("A1")   'change accordingly
    
    Cnt = 0
    For Each Sht In ThisWorkbook.Worksheets
        If Sht.Name <> Rng.Parent.Name Then
            Cnt = Cnt + 1
            Rng.Parent.Hyperlinks.Add _
                Anchor:=Rng.Offset(Cnt - 1, 0), _
                Address:=vbNullString, _
                SubAddress:=Sht.Name & "!A1", _
                TextToDisplay:=Sht.Name
        End If
    Next Sht

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,083
Messages
6,128,718
Members
449,465
Latest member
TAKLAM

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top