嵌套的IF语句'对象定义'错误?

时间:2018-06-05 19:34:58

标签: excel vba excel-formula

如果列F在单元格中没有任何值,我希望列AX执行VLOOKUP。如果是,我希望它显示最后附加的嵌套IF语句中的内容。为什么我得到了

  

对象定义错误

With .Range("AX2")
    .Formula = "=IF(F2="""",VLOOKUP(A2,[PS_Export.xlsx]ps!$A:$AG,33,FALSE),IF(AR176<=300000,AR176*0.3,IF(AND(AR176>300000,AR176<=500000),((AR176-300000)*0.35)+90000,IF(AND(AR176>500000,AR176<=1000000),((AR176-500000)*0.4)+160000,IF(AR176>1000000,((AR176-1000000)*0.45)+360000,))))))"
    .AutoFill Destination:=Range("AX2:AX" & lastrow)
End With

1 个答案:

答案 0 :(得分:1)

答:AG只有33列,而不是34.尝试更改为33或范围为A:AH,

With .Range("AX2:AX" & lastrow)
    .Formula = "=IF(F2=text(,), VLOOKUP(A2,$A:$AG, 33, FALSE), IF(AR176<=300000, AR176*0.3, IF(AR176<=500000, (AR176-300000)*0.35+90000, IF(AR176<=1000000, (AR176-500000)*0.4+160000, (AR176-1000000)*0.45+360000))))"
End With