Hyperlinks in Case Statement

mgiehm

New Member
Joined
May 31, 2011
Messages
16
Hello. Here is what I'm trying to do. I have created a combo box that shows a list of file names. I would like to have those file names become hyperlinks to the actual files. Through some research I am finding that this is either very difficult to do or near impossible. So my question is this, is it possible to create a Case Statement that would create a hyperlink in the field where the combo box is sending its Linked Cell is? Any help would be greatly appreciated.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi mgiehm,

You don't need to use the Linked Cell to do what you describe.

Below are some examples that will follow a hyperlink address directly from the selection
of an item in the ActiveX ComboBox.

Rich (BB code):
Private Sub ComboBox1_Change()
    Dim strChoice As String
    With ComboBox1
        strChoice = .List(.ListIndex, 0)
    End With
    With ActiveWorkbook
        Select Case strChoice
            Case "MrExcel" 'Hyperlink to a URL address
                .FollowHyperlink Address:="http://www.mrexcel.com/forum/", _
                    NewWindow:=True
 
            Case "MyFile" 'Hyperlink directly to a filepath
                .FollowHyperlink Address:="C:\TEST\MyFile.pdf"
 
            Case "Follow Text at D2" 'Hyperlink to an indirect address
                                     'D2 is "http://www.google.com"
                    .FollowHyperlink _
                        Address:=Sheets("Sheet1").Range("D2").Value
            Case Else
                MsgBox "No links associated with: " _
                    & strChoice
        End Select
    End With
End Sub
 
Last edited:
Upvote 0
Jerry,

Thank you so much for your reply. It's exactly what I am looking for. I input in the code changed to my file locations and am getting an error on this line.

Code:
strChoice = .List(.ListIndex, 0)</pre>

The error says Object required. My combo box list is populated from a list on a different sheet that I have named LockList if that matters. Once again thanks for your help!!
 
Upvote 0
There are two kinds of ComboBoxes: ActiveX and Form objects.
Do you know which type you are using?
The code above is written for an ActiveX ComboBox.
 
Upvote 0
I'm using an Active X combo box. To get your code to work I had to change that line to point to the linked cell. Once I did that the code worked beautifully. Thank you.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,881
Members
452,948
Latest member
Dupuhini

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