Recently I try to make a new macro for Excel Workbooks where the user can input the range of cell that need to add hyperlinks, where each cell have value/name of an images
Sub RelinkImage()
Dim xStr As String
Dim xRange As Range
Dim xCell As Range
Dim xAddress As String
On Error Resume Next
xAddress = Application.ActiveWindow.RangeSelection.Address
Set xRange = Application.InputBox("Please select a range", , xAddress, , , , , 8)
Application.ScreenUpdating = False
For Each xCell In xRange
xStr = xCell.Value
xCell.Hyperlinks.Add Address:="C:\EnQuest Anomalies Documents\Images\" + xStr + ".png", TextToDisplay:=xStr
xCell.Font.Size = 10
Next
Application.ScreenUpdating = True
MsgBox "C:\EnQuest Anomalies Documents\Images\" + xStr + ".png"
End Sub
However the code doesn't put any hyperlinks even though the MsgBox still show the correct link.
Do I need to declare xCell as Hyperlinks even when I try to get xCell.value from each cells?
If there any modification I need to do to achieve this?