我正在尝试使用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)"
并且错误是"应用程序定义的错误或对象定义的错误"