【问题标题】:How can I find the hyperlinks referring to the cell in Excel ? Reverse of Hyperlink如何在 Excel 中找到引用单元格的超链接?反向超链接
【发布时间】:2021-02-20 00:19:20
【问题描述】:

您好,我想找到一种方法来追溯引用单元格的超链接。 例如: A列中有5个随机单元格通过超链接引用D2单元格。所以当我去 D2 时,我怎么知道引用 D2 的单元格是什么。

非常感谢您的回答。

谢谢。

【问题讨论】:

  • 超链接是插入还是使用HYPERLINK()工作表函数创建的??
  • 通过右键单击单元格并单击“插入链接”为每个单元格创建超链接,然后链接到同一工作簿(不同工作表)中的单元格

标签: excel excel-formula hyperlink cell traceability


【解决方案1】:

检测特定超链接

  • 在一个工作表的A 列中,尝试查找与另一工作表上的单元格D2 链接的单元格,并将找到的单元格的地址写入立即窗口。

守则

Option Explicit

Sub detectHyperlinks()
    
    ' Source
    Const srcName As String = "Sheet1"
    Const srcFirst As String = "A1"
    ' Destination
    Const dstName As String = "Sheet2"
    Const dCellAddress As String = "D2"
    
    ' Define Source Column Range.
    With ThisWorkbook.Worksheets(srcName)
        Dim LastRow As Long
        LastRow = .Cells(.Rows.Count, .Range(srcFirst).Column).End(xlUp).Row
        Dim rng As Range
        Set rng = .Range(cFirst).Resize(LastRow - .Range(cFirst).Row + 1)
    End With
   
   ' Define Destination Address String.
    Dim dAddr As String
    dAddr = dstName & "!" & dCellAddress
    
    Dim cel As Range    ' Current Cell in Source Range
    Dim sAddr As String ' Source Address String
    
    ' Iterate through cells in Source Column Range.
    For Each cel In rng.Cells
        ' Evaluate if current cell does not contain an error or blank value.
        If Not IsError(cel) And Not IsEmpty(cel.Value) Then
            ' Evaluate if current cell contains a hyperlink.
            If cel.Hyperlinks.Count > 0 Then
                ' Write current cells Sub Address to Source Address String
                ' and remove the "'" and "$" characters.
                sAddr = Replace(cel.Hyperlinks(1).SubAddress, "'", "")
                sAddr = Replace(sAddr, "$", "")
                ' Allowing different case (vbTextCompare), evaluate
                ' if Source and Destination Address Strings are equal.
                If StrComp(sAddr, dAddr, vbTextCompare) = 0 Then
                    ' Do what you need to do with the found cell.
                    ' For example print its address to the Immdediate window.
                    Debug.Print cel.Address
                End If
            End If
        End If
    Next cel

End Sub

【讨论】:

    猜你喜欢
    • 2011-01-17
    • 2016-08-23
    • 1970-01-01
    • 1970-01-01
    • 2014-12-03
    • 1970-01-01
    • 2022-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多