.FormulaR1C1 Iferror(Vlookup运行时1004

时间:2014-08-20 18:09:38

标签: excel-vba vba excel

当我拿出IFERROR时,我的代码有效,但当它在那里时,我得到运行时错误1004。

任何人都知道为什么?

Sub datacleanup()

Dim masterBook As Excel.Workbook
Dim dataSht As Worksheet
Dim rowLength As Integer
Dim ctrlPnl As Worksheet

Application.ScreenUpdating = False

Set masterBook = Excel.Workbooks("Working - Vendor Document Status Report.xlsm")
Set dataSht = masterBook.Worksheets("Data")
Set ctrlPnl = masterBook.Worksheets("Controlpanel")
dataSht.Activate

rowLength = dataSht.Range("A3").End(xlDown).Row

With Range("B3:B" & rowLength)
    .FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],Controlpanel!R2C1:R100C6,3,False),"")"
    .Value = .Value
End With
Application.ScreenUpdating = True


End Sub

干杯

1 个答案:

答案 0 :(得分:1)

您必须使用“”

在公式字符串中转义value-if-error双引号(“”)的=IFERROR部分

更改

"=IFERROR(VLOOKUP(RC[-1],Controlpanel!R2C1:R100C6,3,False),"")"

"=IFERROR(VLOOKUP(RC[-1],Controlpanel!R2C1:R100C6,3,False),"""")"