sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,404
- Office Version
- 2016
- Platform
- Windows
I'm using this procedure to try and add a hyperlink to a range of cells but I keep getting a run time error:
I'm getting a run time error 5, invalid procedure call or argument and it fails on this line:
Can anyone advise why and how to resolve it?
VBA Code:
Dim LastRow As Long
Dim WS As Worksheet
Dim Cell As Range
Set WS = ThisWorkbook.Sheets("COPY")
LastRow = WS.Range("A65536").End(xlUp).Row
Application.ScreenUpdating = False
For Each Cell In WS.Range("A2:A" & LastRow)
Path = "ds://" & Cell.Offset(0, 7).Value
ScreenTip = "Link"
TextToDisplay = Cell.Offset(0, 1).Value
Cell.Offset(0, 8).Select
ActiveCell.Hyperlinks.Add Anchor:=Selection, Address:=Path, ScreenTip:=ScreenTip, TextToDisplay:=TextToDisplay
Next
WS.Range("I2:I" & LastRow).Select
With Selection.Font
.Name = "Tahoma"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleSingle
.ThemeColor = xlThemeColorHyperlink
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
WS.Range("A2").Select
Application.ScreenUpdating = True
I'm getting a run time error 5, invalid procedure call or argument and it fails on this line:
VBA Code:
ActiveCell.Hyperlinks.Add Anchor:=Selection, Address:=Path, ScreenTip:=ScreenTip, TextToDisplay:=TextToDisplay
Can anyone advise why and how to resolve it?