Macros and Hyperlinks

steve case

Well-known Member
Joined
Apr 10, 2002
Messages
823
I have a hyperlink in Cell A4 [ =HYPERLINK(B4,E4) ] I can click on it and it opens the webpage just fine.
I would like to have a macro open the web page but I am having no luck trying to figure out from Microsoft Visual Basic Help how to do that.

It's interesting, hyperlinks copied directly in from the web like the one I have in Cell J4 opens with a macro I recorded just as nicely as you please:

Code:
Range("J4").Select
    Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
But change that to:

Code:
Range("A4").Select
    Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=False
in order to open my formula generated link, and it crashes.

So I need help
 
Corrected code
Code:
Sub Convert_To_Hyperlinks()
    Dim Cell As Range
    For Each Cell In Range("B4", Range("B" & Rows.Count).End(xlUp))
        If Not IsEmpty(Cell) Then
            ActiveSheet.Hyperlinks.Add Anchor:=Cell.Offset(, -1), _
                                        Address:=Cell.Value, _
                                        ScreenTip:=Cell.Offset(, 3).Value, _
                                        TextToDisplay:=Cell.Offset(, 3).Value

        End If
    Next Cell
End Sub

Fantastic!

You know, that's a couple hundred dollars worth of information, and I get it for free here. What a fantastic site (-:

Oh, yes, it worked.
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

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