Excel VBA:尝试添加超链接时出现错误1004

这一系列的命令似乎导致运行时错误:1004我想知道这个错误的原因是什么。

如果我没有Activesheet.Hyperlinks.add行的单元格值设置正确,只是错过了超链接…这会让我觉得我已经失去了xCell引用,但我已经放在超链接之前的debugging语句。添加,它似乎是可访问的。

示例url: http : //www.walmart.com/ip/Transformers-Robots-in-Disguise-3-Step-Changers-Optimus-Prime-Figure/185220368

For Each xCell In Selection Url = xCell.Value If Url = "" Then 'Do Nothing ElseIf IsEmpty(xCell) = True Then 'Do Nothing ElseIf IsEmpty(Url) = False Then splitArr = Split(Url, "/") sku = splitArr(UBound(splitArr)) xCell.Value = "https://www.brickseek.com/walmart-inventory-checker?sku=" & sku 'Error happens on next command ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:=xCell.Formula End If Next xCell 

不要与.Value
不要使用。 公式

 Sub demo() Dim s As String, xCell As Range s = "http://www.walmart.com" Set xCell = Range("B9") ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:=s, TextToDisplay:=s End Sub 

是一个典型的工作例子。