宏将单元格超链接到自身

宏将单元格超链接到自身

本文介绍了宏将单元格超链接到自身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个允许我双击超链接的宏,它根据我点击的单元格显示来自另一张表的信息。

I have already created a macro that allows me to double click a hyperlink and it displays information from another sheet based on the cell that I have clicked on.

现在我想自动化超链接过程,我需要的是一个宏,它将获取一个名称列表并将所有这些单元格超链接到自己。到目前为止,我有一个宏超链接激活的单元格,但返回值为0但是超链接(第一组代码)

Now I would like to automate the hyperlinking process, what I need is a macro that will take a list of names and hyperlink all of those cells to themselves. so far I have a macro that hyperlinks the activated cell but returns a value of 0 but is hyperlinked ( first set of code)

我将包括我记录的宏手动添加宏

I will include the macro that I recorded from manually adding the macro as well

Sub HyperLinkME()

frmla = "=HYPERLINK(" + Chr(34) + "#'" + ActiveSheet.name + "'!" +ActiveCell.Address + Chr(34) + "," + ActiveCell.Address + ")"
ActiveCell.Formula = frmla

End Sub

我记录的宏如下:

Sub ManualHyperlink()
'
' ManualHyperlink Macro
'
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
    "Schedule!A3", TextToDisplay:="dale"
End Sub

提前感谢您提供任何帮助!

Thank you in advance for any and all help!

推荐答案

选择一些单元格并运行:

Sub HyperAdder()
   For Each r In Selection
      ActiveSheet.Hyperlinks.Add Anchor:=r, Address:="", SubAddress:=r.Parent.Name & "!" & r.Address(0, 0), TextToDisplay:="myself"
   Next r
End Sub

在单元格中插入超链接以跳转到自己。

to insert hyperlinks in the cells to jump to themselves.

要保留单元格的内容,请使用:

To preserve the cell's contents, use:

Sub HyperAdder()
    Dim r As Range, s As String
    For Each r In Selection
        If Len(r.Text) = 0 Then
            s = "X"
        Else
            s = r.Text
        End If
        ActiveSheet.Hyperlinks.Add Anchor:=r, Address:="", SubAddress:=r.Parent.Name & "!" & r.Address(0, 0), TextToDisplay:=s
    Next r
End Sub

这篇关于宏将单元格超链接到自身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 11:56