Add column to Hyperlinked list of Worksheets (New to VBA)

absltd

New Member
Joined
Feb 18, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
I found the following VBA Code online for creating an index of sheets and it works perfectly to create a single column (A2:A10, A1 showing "INDEX"), of Hyperlinked Sheets; however, as always, I would like to add some additional functionality. In each sheet, I have a value (Document Number in cell C3) that I would like to show up in the column next to the Hyperlinked Sheet (B2:B10, with B1 showing "Doc Number")

VBA Code:
Private Sub Worksheet_Activate()
    'Define variables
    Dim ws As Worksheet
    Dim row As Long
    row = 1
    'Clear the previous list and add "INDEX" title
    With Me
        .Columns(1).ClearContents
        .Cells(1, 1) = "INDEX"
    End With
    'Loop through each sheet to add a corresponding hyperlink by using the name of the worksheet
    For Each ws In Worksheets
        If ws.Name <> Me.Name And ws.Visible = xlSheetVisible Then
            row = row + 1
            Me.Hyperlinks.Add Anchor:=Me.Cells(row, 1), _
             Address:="", _
             SubAddress:="'" & ws.Name & "'!A1", _
             ScreenTip:="Click to go to sheet " & ws.Name, _
             TextToDisplay:=ws.Name
        End If
    Next ws
    'Adjust the width of first column by the longest worksheet name
    Me.Columns(1).AutoFit
End Sub

Any help would be greatly appreciated :)
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,215,731
Messages
6,126,537
Members
449,316
Latest member
sravya

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