使用表单将链接插入当前单元格

时间:2017-05-21 22:20:47

标签: excel excel-vba vba

由于某种原因,我遇到了比预期更多的麻烦,将链接的锚设置为这段代码中的活动单元格。我想使用这个表单,以便人们可以使用它来插入他们定义的链接,以及他们在所选单元格中定义的标题。任何帮助将不胜感激。

Private Sub Insert_Click()

    With ActiveSheet
     .Hyperlinks.Add Anchor:=Range(ActiveCell), _
     Address:="" & TextBox2 & "", _
     ScreenTip:="Ay yo fam what it do?", _
     TextToDisplay:="" & TextBox1 & ""
    End With

InsertLink.Hide
Unload InsertLink

End Sub

1 个答案:

答案 0 :(得分:0)

试用此源代码

Private Sub Insert_Click()

Dim rng As Range

    Set rng = ActiveCell

    With ActiveSheet
         .Hyperlinks.Add Anchor:=rng, Address:="" & TextBox2 & "", _
     ScreenTip:="Ay yo fam what it do?", _
     TextToDisplay:="" & TextBox1 & ""
    End With

InsertLink.Hide
Unload InsertLink

End Sub