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?
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
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
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'
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.