Opening Selected Hyperlink DISPLAYING TEXT in Default Browser in MS Excel

0 votes

I solved a portion of my issue and used Excel to open hyperlinks in a number of chosen cells. However, it only functioned if the hyperlink was visible and not covered by "friendly text."

Everything works perfectly and the hyperlinks (URLs) open in the default browser when I use the code below to select cells with hyperlinks (URLs). I want to be able to click on hyperlinks that have "friendly text" displayed on them. =HYPERLINK("http://jsvp/MoveImage.aspx?t=1&sku="&A13,A4). The cells display the word "upload" in this manner.

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

I get a Run-time error '-2147221014 (800401ea)' I Cannot open the specified file. 

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

Credit to: PETER ALBERT (https://stackoverflow.com/users/1867581/peter-albert?tab=profile) for his 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
Oct 7 in Others by Kithuzzz
• 20,660 points
72 views

1 answer to this question.

0 votes

Try this code:

  Sub Open_SelectedTextlinks()
If Not TypeOf Selection Is Range Then Exit Sub
For Each c In Selection.Cells
    If c.Hyperlinks.Count = 0 Then

With Worksheets(1)
 .Hyperlinks.Add Anchor:=.Range("a5"), _
 Address:="https://example.microsoft.com", _
 ScreenTip:="Microsoft Web Site", _
 TextToDisplay:="Microsoft"
  Range("A5").Select
    Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
End With
    End If
Next

End Sub
answered Oct 7 by narikkadan
• 37,660 points

Related Questions In Others

0 votes
1 answer

How to open .xlsx files in MS Excel from VS Code?

Hello, to open xlxs files, or files ...READ MORE

answered Feb 17 in Others by gaurav
• 22,040 points
281 views
0 votes
1 answer

In Excel, how to find a average from selected cells

If one has the dynamic array formula ...READ MORE

answered Oct 9 in Others by narikkadan
• 37,660 points
67 views
0 votes
1 answer
0 votes
1 answer

How can I find and replace text in Word using Excel VBA?

Try this code Option Explicit Const wdReplaceAll = 2 Sub ...READ MORE

answered Oct 15 in Others by narikkadan
• 37,660 points
115 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,720 points
454 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
2,228 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9 in Others by gaurav
• 22,040 points
71 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16 in Others by Edureka
• 13,640 points
210 views
0 votes
1 answer

Split text cells in 70 character chunks in Excel

You can do this using Power Query Data ...READ MORE

answered Oct 2 in Others by narikkadan
• 37,660 points
67 views
0 votes
1 answer

SharePoint - Excel Online - Edit in Excel and Edit in Browser multiple users

Here is the Microsoft article regarding co-authoring https://support.office.com/en-us/article/Collaborate-on-Excel-workbooks-at-the-same-time-with-co-authoring-7152aa8b-b791-414c-a3bb-3024e46fb104?ui=en-US&rs=en-US&ad=US When ...READ MORE

answered Oct 3 in Others by narikkadan
• 37,660 points
203 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP