2016-11-10 66 views
0

我必須要工作如下圖所示Hyperlink.add錨與.Cells代替.Range

With Cells(emptyRow, 13) 
    .Hyperlinks.Add Anchor:=.Cells(emptyRow, 13), _ 
    Address:=EmailLinkTextBox.Value, TextToDisplay:="Link" 
End With 

一些代碼似乎不,我相信這是由於錨,因爲我發現,描述對於anchor來說,它可以是Range或Shape對象。

這是問題嗎,如果有的話,是否有它的工作?

謝謝

+0

感謝您的評論,它指出我在正確的方向,並解決了我的問題。代碼現在簡單地是'.Hyperlinks.Add Anchor:=。Cells(emptyRow,13),Address:= EmailLinkTextBox.Value,TextToDisplay:=「Link」' –

+0

我想我可能會不小心刪除了原來的評論,對不起! –

回答

0

你是一個With Cells(emptyRow, 13)塊(即相當於Cells(emptyRow, 13).Cells(emptyRow, 13)內錨設置爲地址.Cells(emptyRow, 13),錨將被放置在Cells(2 * emptyRow - 1, 2 * 13 - 1)

你可能想改變錨僅僅是Cells(emptyRow, 13) - 即與替換代碼:

With Cells(emptyRow, 13) 
    .Hyperlinks.Add Anchor:=Cells(emptyRow, 13), _ 
    Address:=EmailLinkTextBox.Value, TextToDisplay:="Link" 
End With 

With Cells(emptyRow, 13) 
    .Hyperlinks.Add Anchor:=.Cells(1, 1), _ 
    Address:=EmailLinkTextBox.Value, TextToDisplay:="Link" 
End With 

注意:A Cell是一個Range對象 - 它只是它只有1 x 1大小。