单击单元格时,excel vba是否将包含单元格引用的超链接插入单元格?

单击单元格时,excel vba是否将包含单元格引用的超链接插入单元格?,vba,excel,Vba,Excel,我想创建代码,当单击单元格时,它会将超链接插入到该单元格中 我正在使用以下代码: 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\purcha

我想创建代码,当单击单元格时,它会将超链接插入到该单元格中

我正在使用以下代码:

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
我想要的是能够用文本构建我的超链接路径的一部分,然后使用RangeB&Active.Row获取超链接url的其余部分,这将从活动行上的单元格中获取值并完成超链接url


执行此操作时,我会收到一条对象未定义错误消息。什么原因导致该错误?

引号符号太多

请试试这个:

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

此项导致的代码错误:

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

在超链接公式内。

在哪一行出现对象未定义错误?