我想在执行VLOOKUP后用空白替换每个N / A或0。
Dim myLastRow As Long
ActiveSheet.UsedRange
myLastRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
Range("S2").Select
ActiveCell.Formula = "=IF(ISNA(VLOOKUP(C[-16],Blad1!C[-16]:C[6],17,FALSE)),"",IF(VLOOKUP(C[-16],Blad1!C[-16]:C[6],17,FALSE)=0,"",VLOOKUP(C[-16],Blad1!C[-16]:C[6],17,FALSE)))"
Selection.AutoFill Destination:=Range("S2:S" & myLastRow), Type:=xlFillDefault
这对我不起作用,我收到错误,但我不知道到底出了什么问题。
ActiveCell.Formula = "=VLOOKUP(C[-16],Blad1!C[-16]:C[6],17,FALSE)"
确实有效,但条件函数没有。
答案 0 :(得分:1)
您收到该错误是因为您试图将""
放在""
之间。将所有""
替换为""""
ActiveCell.Formula = "=IF(ISNA(VLOOKUP(C[-16],Blad1!C[-16]:C[6],17,FALSE)),"""",IF(VLOOKUP(C[-16],Blad1!C[-16]:C[6],17,FALSE)=0,"""",VLOOKUP(C[-16],Blad1!C[-16]:C[6],17,FALSE)))"