本文介绍了获取Excel UDF以返回超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前要获取 UDF 以返回超链接,我使用类似以下内容的

Currently to get a UDF to return a hyperlink I use something like:

Public Function HyperActive() As String
    HyperActive = "http://www.cnn.com"
End Function

在工作表单元格中,我使用:

and in a worksheet cell, I use:

=HYPERLINK(hyperactive(),"news")

创建一个不错的可点击"链接.

to make a nice, "click-able" link.

我希望UDF直接返回可点击"链接.我尝试过:

I would like to have the UDF return a "click-able" link directly. I have tried:

Public Function HyperActive() As Hyperlink
    Dim h As Hyperlink
    h.Address = "http://www.cnn.com"
    Set HyperActive = h
End Function

仅在单元格中返回 #VALUE!!如何使它工作?

just returns #VALUE! in the cell! How can get this to work??

推荐答案

超链接喜欢添加到工作表中.如果愿意,可以将它们添加到两个范围内.此功能只会添加该网站,您可以随时对其进行充实以获取更多喜欢的参数.

Hyperlinks like to be added to worksheets. You can add them to ranges two if you like. This function will add just that site, you can always flesh it out to take more args of you like.

它将超链接添加到当前选定的单元格.尽管您也可以将其更改为您喜欢的任何内容.

It adds the hyperlink to the current selected cell. Though you could just as well change it to what ever you liked.

Public Function HyperActive(ByRef rng As Range)
With ActiveSheet.Hyperlinks
.Add Anchor:=rng, _
     Address:="http://www.cnn.com", _
     ScreenTip:="Click to go to the Cnn Website", _
     TextToDisplay:="CNN Website"
End With
End Function

Sub Calling_The_Hyper_link()
Call HyperActive(Selection)
End Sub

如果添加公共功能 HyperActive(byref sh作为工作表,ByRef rng作为范围),则您也可以控制它进入哪个表.

If you add Public Function HyperActive(byref sh as worksheet, ByRef rng As Range) you could control which sheet it goes in too.

这篇关于获取Excel UDF以返回超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 08:11