运行时错误1004,vba正在添加超链接
有人能在我需要的时候帮助我吗。我已经创建了一个运行时错误1004,vba正在添加超链接,vba,excel,hyperlink,runtime-error,Vba,Excel,Hyperlink,Runtime Error,有人能在我需要的时候帮助我吗。我已经创建了一个用户表单,该表单根据列表框中的下拉列表输入超链接 尽管超链接在按下submit按钮时实际进入,但我仍然收到 运行时错误1004。应用程序定义或对象定义错误 当我调试ws.cells(iRow,4)时,该行高亮显示了吗 Private Sub Comm1_Click() Dim iRow As Long Dim ws As Worksheet Dim ws2 As Worksheet Dim rng As Range Set ws = Worksh
用户表单
,该表单根据列表框中的下拉列表输入超链接
尽管超链接在按下submit按钮时实际进入,但我仍然收到
运行时错误1004。应用程序定义或对象定义错误
当我调试ws.cells(iRow,4)
时,该行高亮显示了吗
Private Sub Comm1_Click()
Dim iRow As Long
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim rng As Range
Set ws = Worksheets("QttOutlay")
Set ws2 = Worksheets("LookupVals")
iRow = ws.Cells.Find(what:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
Set rng = ws.Cells(iRow)
ws.Cells(iRow, 2).Value = RmRef.Value
ws.Cells(iRow, 3).Value = RetMod.Value
ws.Cells(iRow, 4).Value = rng.Parent.Hyperlinks.Add(Anchor:=rng, Address:=WorksheetFunction.VLookup(RetMod.Value, ws2.Range("A:B"), 2, False), TextToDisplay:="Info")
ws.Cells(iRow, 5).Value = OrdCod.Value
ws.Cells(iRow, 6).Value = hmm.Value
ws.Cells(iRow, 7).Value = lmm.Value
ws.Cells(iRow, 8).Value = rdtype.Value
ws.Cells(iRow, 9).Value = dtt.Value
ws.Cells(iRow, 10).Value = Wtt.Value
ws.Cells(iRow, 11).Value = Qt.Value
ws.Cells(iRow, 12).Value = LPc.Value
ws.Cells(iRow, 13).Value = Dt.Value
ws.Cells(iRow, 14).Value = (LPc.Value * Dt.Value) * Qt.Value
End Sub
返回您正试图分配给单元格值的超链接对象:ws.cells(iRow,4).value=rng.Parent.Hyperlinks.Add(…)
。那不行
我猜ws.Cells(iRow,4)
应该是超链接的锚,比如:anchor:=ws.Cells(iRow,4)
所以不是
ws.Cells(iRow, 4).Value = rng.Parent.Hyperlinks.Add(Anchor:=rng, Address:=WorksheetFunction.VLookup(RetMod.Value, ws2.Range("A:B"), 2, False), TextToDisplay:="Info")
你应该用这样的东西替换整条线
ws.Hyperlinks.Add Anchor:=ws.Cells(iRow, 4), Address:=WorksheetFunction.VLookup(RetMod.Value, ws2.Range("A:B"), 2, False), TextToDisplay:="Info"
返回您正试图分配给单元格值的超链接对象:ws.cells(iRow,4).value=rng.Parent.Hyperlinks.Add(…)
。那不行
我猜ws.Cells(iRow,4)
应该是超链接的锚,比如:anchor:=ws.Cells(iRow,4)
所以不是
ws.Cells(iRow, 4).Value = rng.Parent.Hyperlinks.Add(Anchor:=rng, Address:=WorksheetFunction.VLookup(RetMod.Value, ws2.Range("A:B"), 2, False), TextToDisplay:="Info")
你应该用这样的东西替换整条线
ws.Hyperlinks.Add Anchor:=ws.Cells(iRow, 4), Address:=WorksheetFunction.VLookup(RetMod.Value, ws2.Range("A:B"), 2, False), TextToDisplay:="Info"