How to create a link to run a VBA routine

jqfranco

New Member
Joined
Dec 27, 2017
Messages
28
Good afternoon
I need to have a text in a certain cell that when clicked on it, color a routine that is placed in a module.

VBA Code:
Folha01.Hyperlinks.Add Range("e13"), Address:="https://www.automateexcel.com/excel/", TextToDisplay:="X", ScreenTip:="This is the link for Automate Excel"
With this code, I can open a page in the browser

VBA Code:
Folha01.Hyperlinks.Add Range("e13"), Address:=vbNullString, SubAddress:="call MF12_ProcurarMECNIF(""Ask"",""99"")", TextToDisplay:="X", ScreenTip:="This is the link for Automate Excel"

With this code, I can't get the routine to start, it gives an error of "The reference is not valid".
Where am I failing and how can I solve this problem.

Thank you for your help
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You could easily use the _SelectionChange event of the worksheet or add a button to call the macro.

If you still want to take the hyperlink route, you can do the following:

Folha01.Hyperlinks.Add Range("e13"), Address:="", TextToDisplay:="X", ScreenTip:="This is the link for Automate Excel"

and then place this in the ThisWorkbook Module:
Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, ByVal Target As Hyperlink) If Target.Range.Address = Folha01.Range("e13").Address Then Call MF12_ProcurarMECNIF("ASk", 99) End If End Sub
 
Last edited:
Upvote 0
Thank you very much for the explanation, but I forgot to explain a very important detail, sorry.

I intend to make a list of all the collaborators we have and in the ID column that identifies it, the ID would have a link that would open on sheet02, the form with the complete data of that collaborator.

Therefore, when creating the list, the ID cell would have to have its own hyperlink.

For example, in the command [ Call MF12_SearchMECNIF("ASk", 99) ], the 99 will be the ID of this coworker.

I think I explained myself better this time, thanks.
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,619
Members
449,240
Latest member
lynnfromHGT

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