Excel には、ハイパーリンクと並べ替えに関連する既知のバグがあります。
KB214328: Excel でこれらのハイパーリンクを含むセルを並べ替えると、ハイパーリンクが削除されるか無効になる
私の場合、Excel (ProjecWise) 以外のドキュメントへのハイパーリンクを作成していることに注意してください。
私の回避策は、すべてのハイパーリンクをテキストとして 1 つの列に保存し、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