2016-11-10 22 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大小。