Hyperlink cell

Cooky857

New Member
Joined
Jan 9, 2019
Messages
16
Hi I need help, I need a VBA that any cell in Column "E" that starts with “https:*” becomes an Active Hyperlink and displays as “Link to Site” and all cells do not become Hyperlinks and are unchanged.

I have tried a few methods (one below) but all convert all cells in E Column to Hyperlinks, Any help would be Great, more than happy to show more failed attempts but seams a but of a waste :)

VBA Code:
Sub Links()

Dim link As Hyperlink
    For Each link In ActiveSheet.Hyperlinks
       link.TextToDisplay = "Voucher Link "
   Next link

  End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
so some of your cells start with "https" and other do not?

you want to convert just the ones that do
 
Upvote 0
Hi

Sorry for the delay, i had trouble with this one.

Hopefully this works for you, as it did for me, test this on a copy of your data.

assuming you have a header row also?

VBA Code:
Sub convert_links()
lr = Range("E" & Rows.Count).End(xlUp).Row
For a = 2 To lr
    If Left(Range("E" & a), 5) = "https" Then Range("e" & a).Hyperlinks.Add Anchor:=Range("e" & a), Address:=Range("e" & a), TextToDisplay:="Voucher Link "
Next a
End Sub
 
Upvote 0
Hi

Sorry for the delay, i had trouble with this one.

Hopefully this works for you, as it did for me, test this on a copy of your data.

assuming you have a header row also?

VBA Code:
Sub convert_links()
lr = Range("E" & Rows.Count).End(xlUp).Row
For a = 2 To lr
    If Left(Range("E" & a), 5) = "https" Then
        With Range("E" & a).Hyperlinks
            Range("e" & a).Hyperlinks.Add Anchor:=Range("e" & a), Address:=Range("e" & a), TextToDisplay:="Voucher Link "
        End With
    End If
Next a
End Sub
 
Upvote 0
please see below

this is all you actually need assuming it works

VBA Code:
Sub convert_links()
For a = 2 To Range("E" & Rows.Count).End(xlUp).Row
    If Left(Range("E" & a), 5) = "https" Then Range("e" & a).Hyperlinks.Add Anchor:=Range("e" & a), Address:=Range("e" & a), TextToDisplay:="Voucher Link "
Next a
End Sub
 
Upvote 0
Solution
please see below

this is all you actually need assuming it works

VBA Code:
Sub convert_links()
For a = 2 To Range("E" & Rows.Count).End(xlUp).Row
    If Left(Range("E" & a), 5) = "https" Then Range("e" & a).Hyperlinks.Add Anchor:=Range("e" & a), Address:=Range("e" & a), TextToDisplay:="Voucher Link "
Next a
End Sub
Hi Squidd, just tested it works perfectly thanks very much
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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