I have code that takes the value of a cells in a single column and then uses that value to create a hyperlink within that same cell. It works with the code below. However I'm at a loss to do the same thing with two different columns on the same worksheet. The code below converts the value in column A into a hyperlink. I want to do the same to column C on the same worksheet but with a different hyperlink. I've tried unsuccessfully by adding a new section of code with a new range for column C. I also attempted to add both columns in the code below with additional variables. I haven't done much VBA coding. Any assistance would be much appreciated.
Code
Private Sub Worksheet_Change(ByVal Target As Range)
Dim sPart As String
Dim rMyTarget As Range, c As Range
maxrow = Range ("A" & Rows.Count).End(xlUp).Row
Const sPath = "http://myurl.default.asp?PopUp"
Set rMyTarget = Intersect(Target, Range("A2:A" & maxrow))
If rMyTarget Is Nothing Then Exit Sub
For Each c In rMyTarget
On Error GoTo CleanUp
Application.EnableEvents = False
sPart = c.Text
If sPart = "" Then
'---delete existing hyperlink if any
If c.Hyperlinks.Count > 0 Then c.Hyperlinks(1).Delete
Else
Me.Hyperlinks.Add _
Anchor:=c, Address:=sPath & c.Text, _
TextToDisplay:=c.Text
End If
Next c
CleanUp:
Application.EnableEvents = True
End Sub
Display More