Using Macro for Hyperlinks

davygryan

Board Regular
Joined
May 26, 2010
Messages
150
I am hoping to have some Hyperlink buttons on a spreadsheet.
I can have the links there and just click the cell but the buttons look that bit fancier.

My link currently is =HYPERLINK(("[L:\General_Data\Cordis_QC\Sample tracker\2011\Tracker 2011.xls]'Tracker'!A1"),"Analytical Sample Tracker")

How do I set up the MAcro to activate the button.
So far I have

Sub Button1_Click()

End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Code:
Sub Button1_Click()
 
End Sub
...a fine start ...

I'll expound a bit with something like this...
Since you seem to have the Hyperlink in the formula, TargetFromHLinkFormula extracts the texty parts to feed to
ActiveWorkbook.FollowHyperlink


Code:
Sub Button1_Click()
ActiveWorkbook.FollowHyperlink TargetFromHLinkFormula(Range("H8")) '< Replace your range here
End Sub
 
Function TargetFromHLinkFormula(rng As Range) As String
With rng
Retval$ = Mid(.Formula, _
InStr(1, .Formula, "[", vbTextCompare) + 1, _
InStr(1, .Formula, "]", vbTextCompare) - 1 - _
InStr(1, .Formula, "[", vbTextCompare) _
)
End With
TargetFromHLinkFormula = Retval$
End Function
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

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