Reputation: 15
I have two columns, one automatically generated (Column B), the other(Column D) with few manual values from automated generated column .
B D
--------------------
1 Col1 Col2
2 12 14
3 13 16
4 14
5 15
6 16
--------------------
I want to automatically Hyperlink Column D, when i enter a new row value in it. e.g. The entry D2 should be =HYPERLINK("#B4", B4)
Now i can calculate B4 with INDEX & MATCH, but how do i automatically hyperlink it? That is to say, if i enter 14 in D2, it should automatically get replaced by =HYPERLINK("#B4, B4).
Upvotes: 0
Views: 187
Reputation: 26591
You have to use an event procedure Worksheet_Change: see this article on ozgrid or this one on Chip Pearson's website.
Something like:
Private Sub Worksheet_Change(ByVal Target As Range)
'Do nothing if more than one cell is changed or content deleted
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
'Trigger the procedure only for the column D
If Not Intersect(Target, Range("D:D")) Is Nothing Then
'Turn off ALL events so the Target change does not trigger another time this sub
Application.EnableEvents = False
'Change the formula for what you ever want
Target.Formula = "=HYPERLINK(""#B4"", B4)"
'Turn events back on
Application.EnableEvents = True
End If
End Sub
You just have to change the formula you want to build.
Upvotes: 1