我试图使用VBA插入VLOOKUP公式但它会引发错误

时间:2018-01-22 16:58:49

标签: vba excel-vba excel-formula excel

我正在尝试使用VBA插入VLOOKUP公式,但我一直收到错误。

Sub CCC()
 Dim Lastrow As Long 'Used for the formulas
   Lastrow = Range("D" & Rows.Count).End(xlUp).Row

Range("B2").formula = "=IFERROR(VLOOKUP(F2,'C:\Users\aNTHONY\[cLASS.xlsx]cLASS'!$B$2:$F$1048576,2,FALSE)"

Range("B2").AutoFill Destination:=Range("B2:B" & Lastrow)

End Sub

但它在该行引发错误:

 Range("B2").formula = "=IFERROR(VLOOKUP(F2,'C:\Users\aNTHONY\[cLASS.xlsx]cLASS'!$B$2:$F$1048576,2,FALSE)"

并且错误是"应用程序定义的错误或对象定义的错误"

0 个答案:

没有答案