Automatic Sheet Hyperlinks Based on Name

szymagic

Board Regular
Joined
Jul 8, 2016
Messages
61
Hello,

I'd like to be able to have excel create a hyperlink to a sheet whenever the sheet name is typed out in a specific range on a "home page"

I currently have this written in a worksheet change event, but I'm fearful that this will severely bog down my spreadsheet once more sheets are created.

Here is my code so far:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)Dim ws As Worksheet
Dim rng As Range: Set rng = Range("A1:A10")
Dim cel As Range
For Each cel In rng.Cells
    For Each ws In ThisWorkbook.Worksheets
        If cel.Value = ws.Name Then
            Application.ActiveSheet.Hyperlinks.Add Anchor:=Cells(cel.Row, cel.Column), Address:="", SubAddress:= _
            "'" & ws.Name & "'!R1C1", TextToDisplay:=ws.Name
        End If
    Next ws
Next cel
End Sub

Is there a way to specify for this code to run only when a change within the defined range is executed, instead of the entire worksheet?

Thank you for your help!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,055
Latest member
excelhelp12345

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