在VBA UDF中添加超链接 [英] Add Hyperlink in VBA UDF

查看:827
本文介绍了在VBA UDF中添加超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过如何编辑超链接 - 但是当用作自定义公式时,我需要添加超链接。

I've seen how to edit a hyperlink - but I need to add a hyperlink when used as a custom formula.

我得到了一个#VALUE 错误,我不知道为什么。有没有人有任何想法为什么当我尝试使用它在一个工作表中 c $ = testit39()

I get a #VALUE error and I'm not sure why. Does anyone have any ideas why I get a #VALUE error when I try to use it in a sheet as =testit39()

Public Function testit39() As String
Application.Volatile
Dim rng As range, milestoneinfo As String, milestonesymbol As String

Set rng = Application.Caller
milestoneinfo = "info"
milestonesymbol = "symbol"
If rng.Hyperlinks.Count > 0 Then
    rng.Hyperlinks(1).address = ""
    rng.Hyperlinks(1).screentip = milestoneinfo
    Else
   ThisWorkbook.ActiveSheet.Hyperlinks.Add Anchor:=rng, _
                               address:="", _
                               screentip:=milestoneinfo

    rng.Hyperlinks(1).screentip = milestoneinfo
    End If

 testit39 = milestonesymbol
 End Function


推荐答案

p>我发现一种方法并不复杂,感谢这个美妙的教程。

I have found a way that is not complicated thanks to this wonderful tutorial..

http://optionexplicitvba.blogspot.co.uk/2011/04/rollover-b8-ov1.html

所以基本上你把它放在一个超链接中,你可以随便做...

So essentially you put it in a hyperlink and you're free to do as you please..

=hyperlink(testit39(), "Wahoo it works!")

这篇关于在VBA UDF中添加超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆