I want to add a hyperlink with a cell destination to a selected cell.
For example, first select range("H3"), then came out an input chatbox, I input "2", the VBA program will insert a hyperlink that links to cell "H2" to cell "H3".
I have tried the code as follows:
Sub test1()
Dim myValue As Variant
myValue = InputBox("Input the cell that you want to link to!", "Please input", H2)
ActiveSheet.Range.Hyperlinks.Add Anchor:=Selection, Address:=Sheets("Selected_Formated").Range("F" & myValue.Value)
End Sub
or
Sub test2()
Dim myValue As Variant
myValue = InputBox("Input the cell that you want to link to!", "Please input", H2)
ActiveSheet.Range.Hyperlinks.Add Anchor:=Range("H3"), SubAddress:="Selected_Formated!" & myValue.Value & ""
End Sub
However, both of the 2 codes reported error like "Require object".
I want to know how to use an inputted variable in this "Hyperlinks.Add" function?
Thank you~