t0ny84
Board Regular
- Joined
- Jul 6, 2020
- Messages
- 205
- Office Version
- 365
- 2016
- 2013
- Platform
- Windows
- Mobile
- Web
Hi,
I am hoping someone could point me in the right direction, I am trying to get a macro to run when a hyperlink is clicked.
The below VBA code works when I use Insert Hyperlink in Excel but not when I use the =HYPERLINK function in a formula.
Code To Call Macro When Link Clicked - I have tried both Workbook_Sheet and Worksheet_ but neither work with =HYPERLINK
Below is an example function, ideally if A1 = 5 then - else show a hyperlink to another sheet within the document else show -.
When I don't have the macro in the editor the link works and takes me to the relevant sheet, when I have the code in the editor it doesn't do anything.
Hopefully this makes sense and thanks in advance!
t0ny84
I am hoping someone could point me in the right direction, I am trying to get a macro to run when a hyperlink is clicked.
The below VBA code works when I use Insert Hyperlink in Excel but not when I use the =HYPERLINK function in a formula.
Code To Call Macro When Link Clicked - I have tried both Workbook_Sheet and Worksheet_ but neither work with =HYPERLINK
VBA Code:
Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, ByVal Target As Hyperlink)
If Target.Parent.Address = "$A$1" Then
Call Hello 'test macro
End If
End Sub
Below is an example function, ideally if A1 = 5 then - else show a hyperlink to another sheet within the document else show -.
VBA Code:
=IF(A1="5","-", HYPERLINK("#"&"'"&MONTH($E$3)&"'!E19","…more tasks found."))
When I don't have the macro in the editor the link works and takes me to the relevant sheet, when I have the code in the editor it doesn't do anything.
Hopefully this makes sense and thanks in advance!
t0ny84