VBA to convert a text Column to clickable Hyperlinks

JohanGduToit

Board Regular
Joined
Nov 12, 2021
Messages
89
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Greetings Experts,

I have a spreadsheet in which column "I", Row 2 to 'Bottom (Variable) contains text values (i.e. https://api.blahblahblah.com/imagefile.png)

What would the vba code be to apply the "Hyperlink" formulae to the entire Column "I", or alternatively to convert values in Column "I" to
clickable hyperlinks?

Thanking you in advance.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Greetings Experts,

I have a spreadsheet in which column "I", Row 2 to 'Bottom (Variable) contains text values (i.e. https://api.blahblahblah.com/imagefile.png)

What would the vba code be to apply the "Hyperlink" formulae to the entire Column "I", or alternatively to convert values in Column "I" to
clickable hyperlinks?

Thanking you in advance.
Found the solution on another thread, hope I did not waste anybody's time!

Solution also 'rename' the underlying hyperlink to another value contained in another column.

Here goes...

VBA Code:
Dim rCell as Range

For Each rCell In .Application.Range("I2:I" & .Application.Cells(Rows.Count, "I").End(xlUp).Row)
            .Application.ActiveSheet.Hyperlinks.Add Anchor:=rCell, Address:=rCell.Value, TextToDisplay:=rCell.Offset(, -3).Value
Next rCell
 
Upvote 0
Solution
This will loop through column A and turn the web addresses to hyperlinks.
VBA Code:
Sub Hyper_It()
    Dim sh As Worksheet, I As Range, rng As Range
    Set sh = ActiveSheet
    With sh
        Set rng = .Range("I2:I" & .Cells(.Rows.Count, "I").End(xlUp).Row)
        For Each I In rng.Cells
            .Hyperlinks.Add Anchor:=.Cells(I.Row, I.Column), Address:=I.Value, TextToDisplay:=I.Value
        Next
    End With

End Sub
 
Upvote 0
Morning Dave,

Thank you for your suggestion; appreciated.

What would the code be to only convert the text values if there are an actual value in cells within column "I" ? In other words, to ignore any <blank> (null) cells in Column "I" and only do the conversion for cells containing an actual value?
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,449
Members
449,083
Latest member
Ava19

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