Sure, if you just want D19 then you can do this:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("D19"), Target) Is Nothing Then If Target.Hyperlinks.Count > 0 Then Target.Hyperlinks.Delete
If Target.Value <> "" Then
Target.Hyperlinks.Add Anchor:=Target, _
Address:="http://server.domain.net/apps/" & Target.Value & "?OpenDocument"
End If
End If
End Sub
If you want the flexibility of having different hyperlink for different cells, then you can use the following code instead.
D19 will have a hyperlink to h ttp://server.domain.net/apps/<D19 Value>?OpenDocument
D20 will have a hyperlink to h ttp://anotherdomain.net/ticket=<D20 Value>
D21 and D22 will both use the same hyperlink address of h ttp://yetanotherone.com/value=, then followed by the contents of the appropriate cell.
Hopefully you can see how you can alter this to fit your needs, but if you have any questions feel free to ask
Private Sub Worksheet_Change(ByVal Target As Range)
Dim target_cell As Range
Dim url As String
For Each target_cell In Target.Cells
url = ""
Select Case Target.Address
Case Range("D19").Address
url = "http://server.domain.net/apps/" & target_cell.Value & "?OpenDocument"
Case Range("D20").Address
url = "http://anotherdomain.net/ticket=" & target_cell.Value
Case Range("D21").Address, Range("D22").Address
url = "http://yetanotherone.com/value=" & target_cell.Value
End Select
If url <> "" Then
' Delete any current hyperlink in the cell
If target_cell.Hyperlinks.Count > 0 Then target_cell.Hyperlinks.Delete
' Put in the new hyperlink if required
If target_cell.Value <> "" Then
target_cell.Hyperlinks.Add Anchor:=target_cell, _
Address:=url
End If
End If
Next
End Sub
Bookmarks