i've been googling this for a while but can't find a proper solution.
I want to have Hyperlink which retrives it's (parts of its) address from a certain cell. I.e. when inserting a hyperlink i want it to refer to a cell value rather than an absolut string so the hyperlinks can easily be changed.
Followed is the sub made:
Sub CreateHyper(ARow As Integer, AColumn As Integer, ASheet As Integer, TargetAdress As String, HName As String)
Sheets(1).Hyperlinks.Add Anchor:=Sheets(ASheet).Cells(ARow, AColumn), _
Address:="'" & Sheets("DATA").Range("A2").Value & "'" & TargetAdress, TextToDisplay:=HName
End Sub
The cell value in A2 is dependent on where the excel is stored could be C:\ or X:\alot_of_folders \ ...\
TargetAdress is not to a cell but to a file on the drive. ...\File.pdf
I Think all other variables are self-explanitory.
So when "A2" is updated all hyperlinks should be updated aswell.
The following works, but the target will not change if A2 is changed since it will be a static, how to make "Sheets("DATA").Range("A2").value a reference?
Sub CreateHyper(ARow As Integer, AColumn As Integer, ASheet As Integer, TargetAdress As String, HName As String)
Sheets(1).Hyperlinks.Add Anchor:=Sheets(ASheet).Cells(ARow, AColumn), _
Address:=Sheets("DATA").Range("A2").Value & TargetAdress, TextToDisplay:=HName
End Sub
Any suggestions?