'Target.Range.Offset - or something like that
I'm trying to accomplish that if you click on a hyperlink (in column P), it would copy the cell in the same row but in column B to another cell (A3).
I'vre tried with the Target.Range. Offset and other ways. But I can't seem to figure it out.
But I just can't get it right. Here's the code, any ideas?
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.Range.Address = "$A$4" Then
MsgBox "This shouldn't happen... Try again"
Else
Dim TargetCell As Range
Set TargetCell = Target.Range
TargetCell.Offset(-13, 0).Copy
Range("Vraagnummer").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Exit Sub
End If
End Sub
Solution 1:[1]
You can use this:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.Range.Address = "$A$4" Then
MsgBox "This shouldn't happen... Try again"
Else
Range("Vraagnummer").Value2 = Cells(Target.Range.Row, "B").Value2
End If
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Rory |