2013-07-08 46 views
3

我有几百个标题的列表,每个条目有几列(即名称,日期等)。在我添加的名称中,只是说“A”,“B”,“C”等,因为它使得滚动浏览文档,查找特定名称,知道位置 - 例如 - “H”开始。在添加数据或排序列表后维护超链接

随着列表的增长,我添加了超链接到文档的顶部,以便能够跳转到A/B/C/etc.-条目。但是,当添加新数据并对其进行排序时,或者按日期或其他方式对列表进行排序时,超链接“转到:A”(作为示例)会与原始单元格A1保持链接 - 尽管该单元格的数据(实际的文本“A”)现在在A42中。

无论如何要维护超链接,通过排序和[主要]添加新的数据?

回答

1

A1中的公式是=HYPERLINK($I1,"Go to: "&H1)将被适当复制下来。

SO17535313 example revised

(= MATCH在作为被搜索的字母相同的范围内“不喜欢”的超链接的细胞。)

可选地在ROW1(但仍然在新ColumnA)和复制下来,而不需要ColumnH:I:

=HYPERLINK("[SO17535313.xlsx]Sheet1!"&"B"&MATCH(CHAR(64+ROW()),B:B,0),"Go to: "&CHAR(64+ROW())) 
+0

非常感谢,通过添加新数据似乎很好。但我遇到了一个奇怪的问题。它适用于“C”和下,但“A”和“B”得到“循环参考警告”。任何想法是什么造成这个?手动输入代码时以及扩展系列时都会发生。 – Zinatic

+0

在添加字母表的其余部分之后,“B”(即“转到:B”超链接)解决了它自己。 “A”仍然被打破,状态栏显示“循环参考:H1”。 (我的清单是在A30:A106,顺便说一句,我改为代码来反映我使用的文档和工作表的名称。) – Zinatic

+0

新代码(公式?)完美工作。非常感谢您的帮助。 – Zinatic

1

Excel中存在一个与超链接和排序相关的已知错误。

KB214328: Hyperlinks are removed or invalid after you sort cells that contain these hyperlinks in Excel

我要指出,在我的情况,我做链接文件的Excel(ProjecWise)之外。

我的工作是将所有超链接作为文本存储在一列中,并使用Excel Hyperlink()函数为另一列中的每一行生成超链接。当您想从外部源(如浏览器)粘贴超链接时,请选择该单元格,然后将链接粘贴到功能区下方的功能框中,而不是直接粘贴到单元格中。这会给你的文本,而不是在单元格中创建超链接对象。

我完全不了解这个问题,但是从我理解Excel处理超链接的方式,单元格中的超链接以某种方式链接到表单对象上的超链接集合。当您对工作表中的行进行排序时,工作表超链接引用开始返回错误的引用。我无法找到工作表超链接引用的唯一'句柄',但注意到h.Parent.Top随着排序而改变。

Public Sub ShowSheetHyperlinks() 
' Use this to demonstrate the issue acknowledged here: http://support.microsoft.com/kb/214328 
' Add some hyperlinks in a column of a spreadsheet and random values in a column next to it. 
' Run this routine. Then sort the values by the first or second column and run this routine again. 
' You may have to do this a few times, and/or copy and paste your hyperlink cells to other cells. 
' Eventually you will see that the results change after the two columns are sorted. 
' (You may not need two columns, but it may help to randomize the sorting.) 

    Dim h As Hyperlink 

    Debug.Print "Hyperlinks on " & ActiveSheet.Name & ": " & ActiveSheet.Hyperlinks.Count 

    For Each h In ActiveSheet.Hyperlinks 
     ' After you sort the list of hyperlinks, you will notice the values in the 
     ' three columns below. I am truncating the address to just see the last 20 characters. 
     Debug.Print h.TextToDisplay, h.Parent.Top, Right(h.Address, 20) 
    Next 

End Sub 
2
  • 保存Excel电子表格“网页”(而不是“单个文件网页”。)
  • 打开“网页”,在Excel版本。
  • 对其进行排序。
  • 将其另存为Excel电子表格。

每个链接都将保存在适当的单元格中。