Monday, March 14, 2016

How to run a macro from an hyperlink event EXCEL VBA

Follow these steps to run a macro from an hyperlink:

First, create manually an hyperlink which is linked to its own cell in EXCEL:
Note you can create hyperlinks automatically using a macro: see post http://domyexcelblog.blogspot.com/2016/03/how-to-add-hyperlinks-for-macro-call.html



Then, create the Hyperlink event in VBA:


Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

MsgBox ("You just clicked on the hyperlink on cell column = " & ActiveCell.Column & ", row = " & ActiveCell.Row)

End Sub


Finally, test your macro: when you click on the hyperlink the following message from your macro will appear:



Created by DoMyExcel.com © | Excel & VBA Consulting | Customized Excel Solutions starting at 89 USD
Services provided to Individuals and Businesses | Free Quote: DoMyExcel@gmail.com

No comments:

Post a Comment