VBA code to rename hyperlink according to value in each row

leonc337

New Member
Joined
Feb 22, 2022
Messages
1
Platform
  1. Windows
Greetings all,

I'm relatively new to VBA and I would like some help on a problem I'm trying to solve for. I have two columns of data and both of them are text initially.
I first ran the VBA below to turn texts in the "Hyperlink" column into clickable links. However, I would also like them to be renamed to the corresponding friendly name using texts showed on the left column. Is there a VBA code that can make this work? If the 2 steps (turn text into hyperlink + rename) can be combined into one that's better. <*** I would only want VBA solution because some of the link exceed formula text limit so formula won't work>

Many Thanks!!!
1.png
2.png
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Give this a try:-
VBA Code:
Sub CreateHyperlink()
    Dim rCell As Range

    For Each rCell In Range("B5:B" & Cells(Rows.Count, "B").End(xlUp).Row)
        ActiveSheet.Hyperlinks.Add Anchor:=rCell, Address:=rCell.Value, TextToDisplay:=rCell.Offset(, -1).Value
    Next rCell
End Sub
 
Upvote 0
This does the trick for converting only cells in column I that contains a value:

VBA Code:
Dim rCell as Range
For Each rCell In .Application.Range("I2:I" & .Application.Cells(Rows.Count, "I").End(xlUp).Row)
            If IsEmpty(rCell.Value) = False Then
                .Application.ActiveSheet.Hyperlinks.Add Anchor:=rCell, Address:=rCell.Value, TextToDisplay:=rCell.Offset(, -3).Value
            End If
Next rCell
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,128
Members
453,021
Latest member
Justyna P

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