Forum Discussion
Why is adding hyperlinks using VBA failing?
- Nov 30, 2021
I see two serious problems:
1) The URLs contain #. Excel cannot handle URLs that contain #.
2) The URLs are extremely long - up to 4812 characters in length. I'm not sure Excel can handle that.
If I try to convert the values in column G directly to hyperlinks, they don't work...
I'm afraid I don't have a solution for you, sorry.
Here you go:
Sub AddHyperlinks()
Dim r As Long
Dim m As Long
Application.ScreenUpdating = False
m = Range("B" & Rows.Count).End(xlUp).Row
For r = 5 To m
ActiveSheet.Hyperlinks.Add Anchor:=Range("A" & r), _
Address:=Range("G" & r).Value, TextToDisplay:=Range("B" & r).Value
Next r
Application.ScreenUpdating = True
End Sub- HansVogelaarNov 30, 2021MVP
Could you attach a sample workbook that demonstrates the problem (without sensitive data)?
- asantos2021Nov 30, 2021Copper Contributor
HansVogelaar of course.
- HansVogelaarNov 30, 2021MVP
I see two serious problems:
1) The URLs contain #. Excel cannot handle URLs that contain #.
2) The URLs are extremely long - up to 4812 characters in length. I'm not sure Excel can handle that.
If I try to convert the values in column G directly to hyperlinks, they don't work...
I'm afraid I don't have a solution for you, sorry.