Hyperlinking Buttons

VL00kup

New Member
Joined
Nov 13, 2017
Messages
9
Is it possible to dynamically assign a hyperlink to a button, based on the value of a cell. That is, so that clicking on a button links to a URL defined in a given cell?

Thank you!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi,

I have done something along the lines of the following in the past.
I am assuming that's what you mean.

Code:
Sub Button1_Click()

Worksheets("Sheet1").Range("C4").Hyperlinks(1).Follow NewWindow:=True

End Sub
 
Last edited:
Upvote 0
Thanks for this. I think it will likely address what I am trying to solve for.

However, I am getting an error when I try to run the macro that says "Runtime error 9... Subscript out of range." Is there something else I need to set-up the script? Apologies if this is a basic question, as I am pretty new to VBA

Thank you
 
Upvote 0
Assuming you will enter something like this in Range("A1")
"CNN"
Then use a script like this:
Code:
Sub Link_Me()
On Error GoTo M
Link = "http://" & Cells(1, 1).Value & ".com"
ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True
Exit Sub
M:
    MsgBox "Cannot open " & Link
End Sub
 
Upvote 0
Check the worksheet the link is on is the right name. I have assumed 'Sheet1' and that the range it refers to is correct. I have assumed the hyperlink is in 'C4'
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,927
Members
449,094
Latest member
teemeren

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