Hyperlink to sheets

jiddings

Board Regular
Joined
Nov 22, 2008
Messages
135
The following code lists the sheet names in a workbook starting at A6 on the "Summary" sheet.
How do I modify the code to change the listed sheet names to hyperlink to each of the named sheets?

Code:
Sub InsertNames()
Worksheets("Summary").Unprotect
Dim N As String
    Dim i As Long, r As Long
    
    For i = 1 To Worksheets.Count
        N = Worksheets(i).Name
        If N <> "Summary" And N <> "Master" And N <> "Names" Then
            r = r + 1
            ActiveSheet.Cells(r + 5, 1).Value = N
        End If
    Next i
Worksheets("Summary").Protect
Worksheets("Summary").Activate
Range("B1").Select
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try

Code:
r = r + 1
           ActiveSheet.Cells(r + 5, 1).Hyperlinks.Add Anchor:=ActiveSheet.Cells(i, 1), Address:="", _
           SubAddress:="'" & N & "'!A1", TextToDisplay:=N
End If
 
Upvote 0
Thanks daverunt,
It works great, except I had to modify the VBA to the following to get the listing to start at Cell A6.

I'm new to adding hyperlinks into VBA. Where can I read more (with VBA examples) on the use of hyperlinks in VBA and the correct context usage?

Thanks again for your help.

Code:
ActiveSheet.Cells(r + 5, 1).Hyperlinks.Add Anchor:=ActiveSheet.Cells(r + 5, 1), Address:="", _
           SubAddress:="'" & N & "'!A1", TextToDisplay:=N
 
Upvote 0
Glad you got it working.
I don't know of any particular source of hyperlink use.
There are many examples on this site.

I would decide what I needed to do first then look for the different ways to do it via Google.
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,542
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