Opening selected hyperlinks hidden by friendly text in default browser

Limey2632

New Member
Joined
Jul 28, 2016
Messages
9
Platform
  1. MacOS
Hi folks,
I was able to find an answer to part of my problem and was able to open hyperlinks in a range of selected (highlighted by dragging cursor) cells in Excel. BUT... It only worked if the hyperlink is showing and not hidden by "friendly text".

When I use the code below to select cells with hyperlinks (URLs) everything is great and they open in the default browser. What I would like is to be able to open Hyperlinks that is displaying "friendly text". . =HYPERLINK("http://jsvp/MoveImage.aspx?t=1&sku="&A13,A4). This shows the word "upload" in the cells.

Sample Hyperlink
=IF(LEN(A3)>5,"",HYPERLINK("https://supercms.company.com/ManageProducts/"&LEFT(A3,5),A3)) This displays a value from Cell A3.

I get the following error when I try to open selected friendly text hyperlinks as shown above..
Run-time error '-2147221014 (800401ea)' Cannot open specified file

QUESTION: Would there be a way open the URLs even if the text was hiding the Hyperlink (URL)?

Credit to: PETER ALBERT (User Peter Albert) for his code.

VBA Code:
Sub Open_SelectedTextlinks()
    Dim c As Range

    If Not TypeOf Selection Is Range Then Exit Sub
    For Each c In Selection.Cells
        If c.Hyperlinks.Count = 0 Then
            ActiveSheet.Hyperlinks.Add Anchor:=c, _
                Address:="http://" & c.Value 'Depending on the content of your cell, remove the "http://" & part
        End If
        c.Hyperlinks(1).Follow
    Next
End Sub

This code works well when the complete URL in the hyperlink is visible in the cell but not when hidden by friendly txt.

QUESTION: One more thing... Can the code be applied to only visible cells in the selection when rows are filtered?

Any hep would be appreciated. I am a novice coder so please could you share any code as fully as possible and let me know what I need to customize if anything.

When code runs on selected friendly text hyperlinks:
select and open.jpg


When I hit Open:
runtime.png




Cheers!
Limey
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,881
Messages
6,175,159
Members
452,615
Latest member
bogeys2birdies

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