Hyperlinks

Tills13

New Member
Joined
Jun 6, 2011
Messages
15
I've written some code that will attach multiple files to an entry in a database and, if there's only one file attached, clicking a hyperlink will take you to that specific file. When there's more than one file, however, I would like to have a userform open with buttons to go to the files...

I've written the following code; however, the code lets the first file open (because that's what's linked) and then opens the window I want.

Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If InStr(Sheets("MTRs").Cells(ActiveCell.Row, 1).Value, "(") Then
    Load Multifile
    Multifile.Show
End If
End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
You could have the hyperlink use a cell reference to the same cell that holds the hyperlink. The Display Text can be the same as you are already using.

If you do that, your UserForm should come up without going to any URL addresses first.
 
Upvote 0
Alright, i've tried pretty much everything, but how do you link to a cell in VBA?

Code:
ActiveSheet.Hyperlinks.Add Anchor:=Cells(Count, 1), Address:=Cells(Count, 1).Address
 
Upvote 0
Try one of these two methods...

Code:
ActiveSheet.Hyperlinks.Add Anchor:=Range("B2"), Address:="", SubAddress:= _
        "Sheet1!B2", ScreenTip:="Tip Text", TextToDisplay:="Display Text"

Code:
ActiveSheet.Hyperlinks.Add Anchor:=Range("B2"), Address:="", SubAddress:= _
        "#B2", ScreenTip:="Tip Text", TextToDisplay:="Display Text"
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

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