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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,214,632
Messages
6,120,652
Members
448,975
Latest member
sweeberry

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