0
votes

I want to create code, which will insert an hyperlink into a cell when that cell is clicked.

I'm using the following code:

If Target.Column = Range("BL1").Column Then
    If Target.Row > 14 And Target.Value = "Attach" Then

    MsgBox "This is fun"
    Range("BL" & Target.Row).Formula = "=HYPERLINK(""\\UKSH000-file06\purchasing\New_Supplier_Set_Ups_&_Audits\ATTACHMENTS\"" & Range(""B"" & Active.Row).Value & "",""Attached"")"

    End If
End If

What I want is to be able to build part of my hyperlink path with text, then get the rest of the hyperlink url using Range("B" & Active.Row), which will get the value from the cell on the active row and complete the hyperlink url.

I get an "Object Undefined Error" message when I do this. What's causing that error?

2
on what line do you get the object undefined error? - Goos van den Bekerom

2 Answers

0
votes

there is too many quote symbols.

Please try this one:

Dim ws As Worksheet
ws = Target.Parent

    If Target.Column = Range("BL1").Column Then
        If Target.Row > 14 And Target.Value = "Attach" Then

        MsgBox "This is fun"
        ws.Hyperlinks.Add _
          Anchor:=Range("BL" & Target.Row), _
          Address:="\\UKSH000-file06\purchasing\New_Supplier_Set_Ups_&_Audits\ATTACHMENTS\" & _
                   Range("B" & Active.Row).Value, _
          TextToDisplay:="Attached"

        End If
    End If
0
votes

Your code error caused by this item:

& Range(""B"" & Active.Row).Value

inside hyperlink formula.