我的代码的目的是在单元格中输入公式。它从一个页面中提取工作簿路径,名称和工作表,并在另一个单元格中使用它(在WS中单击宏按钮)以查找值。 当我运行我的代码时,我得到错误:对象'range'的方法'value'失败 我已经看过其他人的问题,但没有找到解决方案。
Sub EquipmentRecord()
Dim CalPath As Variant
Dim CalWB As Variant
Dim CalWS As Variant
Dim FullCalPath As Variant
CalPath = Worksheets("Document Properties").Range("H16")
CalWB = Worksheets("Document Properties").Range("H17")
CalWS = Worksheets("Document Properties").Range("H18")
FullCalPath = "'" & CalPath & "[" & CalWB & "]" & CalWS & ""
ActiveCell.Offset(1).EntireRow.Insert
ActiveCell.Offset(1).EntireRow.Select
Range("F" & ActiveCell.Row).Value = ("=VLOOKUP(RC[-1]," & FullCalPath & "!R1C1:R100C26,13,FALSE)")
End Sub
答案 0 :(得分:0)
FullCalPath = "'" & CalPath & "[" & CalWB & "]" & CalWS & ""
似乎缺少最后双引号之间的单引号
FullCalPath = "'" & CalPath & "[" & CalWB & "]" & CalWS & "'"