向单元格添加公式。出现1004错误

问题描述 投票:0回答:2

我正在尝试在单元格中添加论坛以创建将在工作表之间跳转的超链接。由于字符串开头的VBA Runtime Error 1004 Application-defined or Object-defined error符号,我不断收到错误=

这是我的代码:

    Public strcelladdress As String
    Public hyperlink1 As String
    Public hyperlink2 As String
    Public hyperlinkfinal As String
    Public columnletter As String
    Public rngTarget As Range
    Public ADVICErow As Integer
    Public CALLrow As Integer
    Public TSHOOTcol As Integer

columnletter = Split(Worksheets("Troubleshooting Advice").Cells(ADVICErow, 1).Address, "$")(1)
columnletter = Right(columnletter, 1)
strcelladdress = columnletter + CStr(ADVICErow)
hyperlink1 = "HYPERLINK(""#'Troubleshooting Advice'!"
hyperlink2 = ",""Link to Troubleshooting Advice"")"
hyperlinkfinal = hyperlink1 + strcelladdress + hyperlink2
Set rngTarget = Worksheets("Call Examples").Cells(CALLrow, TSHOOTcol)
rngTarget.Formula = "=" + hyperlinkfinal

我想念的是什么?有人可以帮忙吗?

excel vba
2个回答
0
投票
Sub AddHyperlinkA() Dim targetsheet As String Dim sht As Worksheet Set sht = ActiveWorkbook.Sheets("Call Examples") targetsheet = "Troubleshooting Advice" columnletter = "A" strcelladdress = columnletter + CStr(ADVICErowtarget) hyperlink1 = "'" & targetsheet & "'!" & strcelladdress hyperlink2 = "Link to Troubleshooting Advice" With sht .Hyperlinks.Add Anchor:=.Cells(CALLrow, TSHOOTcol), _ Address:="", _ SubAddress:=hyperlink1, _ ScreenTip:=hyperlink2, _ TextToDisplay:=hyperlink2 End With End Sub
© www.soinside.com 2019 - 2024. All rights reserved.