VBA for setting active URL

jesper117

New Member
Joined
Apr 28, 2011
Messages
2
Hi. I really want an VBA function that "works like" =HYPERLINK, e.g. when execute as a forumla the link in the cell is clickabl afterwards. The closest I've found is:

Code:
Option Explicit
Function myHyperLink()

With Application.Caller
.Parent.Hyperlinks.Add Anchor:=.Cells, _
Address:="http://www.microsoft.com"
End With

myHyperLink = "Click me!"
End Function

From: http://www.sqldrill.com/excel/programming-vba-vb-c-etc/1002172-udf-returns-hyperlink.html

But is doesn't work in "my hands" just gives a
"a value used in the formula is of the wrong datatype" when commenting out the "with"-section it works as normal (but doesn't give a hyperlink)..

How can I .. in VBA do the same thing as =HYPERLINK does, (I want to do more, thus I cannot use).
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
It suggests putting =Hyperlink into ActiveCell.formula.. which wouldn't work since I need it to work like a formula itselv .. =myhyperlink() is allready in formula.. Or I have missed some obvious logic here...
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,735
Members
452,939
Latest member
WCrawford

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