Macro to insert a hyperlink in several worksheets

Cesylia

New Member
Joined
Aug 15, 2014
Messages
2
I am creating several books that have several worksheets and each sheet needs a link to a summary sheet. I am lost trying to create a macro that will do this. If in addition, I could run a macro that will insert a hyperlink from the summary sheet back to each worksheet... that would be absolutely awesome.

Hope someone can help me out there. I am not an expert with macros.

Thank you!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Code:
Sub AddLinks()
    Dim ws As Worksheet
    
    'go through each sheet in this workbook
    For Each ws In ThisWorkbook.Worksheets
        'if the sheet is not named summary then add hyperlink
        If ws.Name <> "Summary" Then
            'anchor is the cell where the hyperlink will be placed
            'subddress is the sheet and cell where the hyperlink points to
            ws.Hyperlinks.Add anchor:=ws.Range("A1"), Address:="", SubAddress:="Summary!A1", TextToDisplay:="Summary Worksheet"
        End If
    Next
End Sub
 
Upvote 0
Hi there, thank you very much for your response. I tried running the module and it works; except that when you click on the hyperlink it doesn't take back to the 'Account Summary' sheet. I tried changing the name, but still it won't jump back to the first page (summary). Any additional tips please?

Code:
Sub AddLinks()
    Dim ws As Worksheet
    
    'go through each sheet in this workbook
    For Each ws In ThisWorkbook.Worksheets
        'if the sheet is not named summary then add hyperlink
        If ws.Name <> "Summary" Then
            'anchor is the cell where the hyperlink will be placed
            'subddress is the sheet and cell where the hyperlink points to
            ws.Hyperlinks.Add anchor:=ws.Range("A1"), Address:="", SubAddress:="Summary!A1", TextToDisplay:="Summary Worksheet"
        End If
    Next
End Sub
 
Upvote 0
You have to change the name in this line:

Code:
If ws.Name<>"Summary" then

also in this line:

Code:
ws.Hyperlinks.Add Anchor:=ws.Range("A1"), Address:="", SubAddress:="Summary!A1", TextToDisplay:="Summary Worksheet"

in this line the SubAddress is basically "NameOfSheet!CellOnThatSheet" so change the name of the sheet here as well and if needed the cell
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,311
Members
449,080
Latest member
jmsotelo

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