Worksheet_FollowHyperlink-获取超链接所在的单元格值 [英] Worksheet_FollowHyperlink - get the cell value in which the hyperlink is located

查看:422
本文介绍了Worksheet_FollowHyperlink-获取超链接所在的单元格值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个单元格中有一个值,当我双击它时,它将带我到命名范围Account_Number(位于另一个工作表上)并更新该值.

I have a value in a cell and when I double click on it it takes me to the Named Range Account_Number (which resides on another worksheet) and updates the value.

我的问题是我想在下面修改我的代码,以便它可以与Worksheet_FollowHyperlink(ByVal Target As Hyperlink)事件一起使用.

My problem is I would like to adapt my code below so it will work with the Worksheet_FollowHyperlink(ByVal Target As Hyperlink) event.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

If (ActiveCell.Column = 23 And Not ActiveCell.Value = "") Then   
    [Account_Number] = ActiveCell.Value
    Application.GoTo Reference:=[Account_Number]
End If

End Sub

我想在单元格J9中放置一个超链接,其中包含值4111,当我单击该超链接时,它将带我到另一个工作表中的命名范围",并将命名范围"的值更新为4111.

I would like to put a hyperlink for instance in cell J9 which contains the value 4111 and when I click on the hyperlink it would take me to the Named Range in the other worksheet and update the value of the Named Range to 4111.

我不确定如何将值动态分配给命名范围".有人可以让我知道这是否可行以及代码应该是什么吗?

I am uncertain how to dynamically assign the value to the Named Range. Can someone please let me know if this is possible and what the code should be?

谢谢

推荐答案

如果您已经建立了到命名单元格的超链接,则将值从超链接源单元格复制到其目标的方法将是:

If you have made a hyperlink to a named cell, the way to copy the value from hyperlink source cell to its target would be:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
    ActiveCell.Value = Target.Parent.Value
End Sub

您可能只想将其应用于指向特定命名单元格的超链接,例如:

You might want to apply this only to hyperlinks to particular named cell, like:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
  If Target.SubAddress = "Account_Number" Then
    ActiveCell.Value = Target.Parent.Value
  End If
End Sub

这篇关于Worksheet_FollowHyperlink-获取超链接所在的单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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