2016-04-28 68 views
1

讓我描述我的情況的小區,Excel的VBA - 引用該超鏈接

基本上,是名「測試」包含文字叫我點擊持有的超鏈接標識的小區。 我想引用這個單元格及其超鏈接到另一個單元格。

如: - 小區標識名稱:測試 名稱:點擊我 超鏈接:www.google.com

在這裏,我想引用測試到另一個細胞以其超鏈接 沿PS =測試只給出了值細胞標識符(點擊我) 但我想要「點擊我的超鏈接」。

這可能嗎?

在此先感謝

Link

+0

據我瞭解這個問題,這應該是可能的。儘管如此,這個網站如果不是免費的代碼寫作服務。然而,我們渴望用**代碼來幫助程序員(和有志之士)。請閱讀[我如何提出一個好問題](http://stackoverflow.com/help/how-to-ask)的幫助主題,以及如何創建[最小,完整和可驗證示例](http ://stackoverflow.com/help/mcve)。之後,請用您迄今編寫的VBA代碼更新您的問題,以完成您希望實現的任務。 – Ralph

+0

謝謝。 我是這個社區的新手。讓我快速瀏覽一下這些鏈接,使其成爲一個更好的問卷。 –

+0

你能解釋一下嗎?我無法獲得上下文。 –

回答

0

試試這個:

Sub CopyHyperlinks() 
    Dim Source As Range 
    Dim Destination As Range 
    Dim SearchRange As Range 

    Set SearchRange = Sheets(1).Range("A1:A5") '---> set your range here 
    Set Source = SearchRange(1, 1) 
    Set Destination = Sheets(1).Range("B1") '---> range will be copied here 

    For Each Source In SearchRange 
     If Source.Hyperlinks.Count > 0 Then 
      Destination.Hyperlinks.Add Destination, _ 
       Source.Hyperlinks(1).Address, , , Source.Text 
     End If 
     Set Destination = Destination(2, 1) 
    Next Source 
End Sub 

here得到這個。