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:
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!
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!