Worksheet_FollowHyperlink not working - even in brand new file

excelschlub

New Member
Joined
Nov 14, 2017
Messages
16
Hello,

I need a hyperlink to open a macro, but I am not able to get it to work. At first I thought it was the larger code it was a part of, but I have tried both of the bare bones codes below to get a hyperlink to open a macro and it is not working. I have even tried closing all other excel files and opening a brand new file.

Option 1 - calling by cell address:
Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
        MsgBox "It worked"
        Exit Sub
    End If
End Sub

Option 2 - calling by hyperlink name:
Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
    If Target.Name = "mymacro" Then
        MsgBox "hyperlink name worked"
        Exit Sub
    End If
End Sub

The hyperlink I have created is in cell A4 on sheet 1 and it has a display name of "mymacro". I am referencing the following: http://learnexcelmacro.com/wp/2012/04/assign-macro-to-hyperlink/

I have tried each of these options independently in brand new .xlsm files. The only thing that happens when I click the link is that the cell (A4) is selected, which is the address of hyperlink. I dont error codes, I dont get anything.

Is there a setting I need to enable or disable?

Thanks for your help!

-Dave
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
If you open the VB Editor, then open the Immediate window (Ctrl+G) and type:

Code:
?Application.Enableevents

and press Return, does it output True or False?
 
Upvote 0
OK, good start! Which module is your code in?
 
Upvote 0
The code must be in a the code module for the worksheet that has the hyperlink. Right-click the sheet tab and choose View Code, then put the code into the window that appears.
 
Upvote 0

Forum statistics

Threads
1,215,821
Messages
6,127,053
Members
449,356
Latest member
tstapleton67

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