我有一个来自VBA且条件为IF
的Excel公式,如果它是真的,我希望它不返回任何内容。
这是我的代码:
Set tbl = .ListObjects("Tableau4")
vCherchee = tbl.DataBodyRange(1, 1)
.PivotTables("Tab1").TableRange1.Select
matrice = Selection.Address(ReferenceStyle:=xlA1, RowAbsolute:=True, ColumnAbsolute:=False)
tbl.DataBodyRange(1, 3).Formula = "=IF(OR(ISNA(VLOOKUP([@[Code Frns]]," & matrice & ",3,FALSE)), ISBLANK(VLOOKUP([@[Code Frns]]," & matrice & ",3,FALSE))),1, VLOOKUP([@[Code Frns]]," & matrice & ",3,FALSE))"
tbl.DataBodyRange(1, 4).Formula = "=IF(OR(ISNA(VLOOKUP([@[Code Frns]]," & matrice & ",4,FALSE)), ISBLANK(VLOOKUP([@[Code Frns]]," & matrice & ",4,FALSE))),1, VLOOKUP([@[Code Frns]]," & matrice & ",4,FALSE))"
tbl.DataBodyRange(1, 5).Formula = "=IF(OR(ISNA(VLOOKUP([@[Code Frns]]," & matrice & ",5,FALSE)), ISBLANK(VLOOKUP([@[Code Frns]]," & matrice & ",5,FALSE))),1, VLOOKUP([@[Code Frns]]," & matrice & ",5,FALSE))"
tbl.DataBodyRange(1, 6).Formula = "=IF(OR(ISNA(VLOOKUP([@[Code Frns]]," & matrice & ",6,FALSE)), ISBLANK(VLOOKUP([@[Code Frns]]," & matrice & ",6,FALSE))),1, VLOOKUP([@[Code Frns]]," & matrice & ",6,FALSE))"
tbl.DataBodyRange(1, 7).Formula = "=IF(OR(ISNA(VLOOKUP([@[Code Frns]]," & matrice & ",7,FALSE)), ISBLANK(VLOOKUP([@[Code Frns]]," & matrice & ",7,FALSE))),1, VLOOKUP([@[Code Frns]]," & matrice & ",7,FALSE))"
tbl.DataBodyRange(1, 8).Formula = "=IF(OR(ISNA(VLOOKUP([@[Code Frns]]," & matrice & ",8,FALSE)), ISBLANK(VLOOKUP([@[Code Frns]]," & matrice & ",8,FALSE))),1, VLOOKUP([@[Code Frns]]," & matrice & ",8,FALSE))"
tbl.DataBodyRange(1, 9).Formula = "=IF(OR(ISNA(VLOOKUP([@[Code Frns]]," & matrice & ",9,FALSE)), ISBLANK(VLOOKUP([@[Code Frns]]," & matrice & ",9,FALSE))),1, VLOOKUP([@[Code Frns]]," & matrice & ",9,FALSE))"
实际上,它返回1,但是如果我什么都不放,它返回0,如果我放""
,它给我一个错误。我怎样才能做到这一点?谢谢。
答案 0 :(得分:0)
感谢GSerg。正确的方法是。
tbl.DataBodyRange(1, 5).Formula = "=IF(OR(ISNA(VLOOKUP([@[Code Frns]]," & matrice & ",5,FALSE)), ISBLANK(VLOOKUP([@[Code Frns]]," & matrice & ",5,FALSE))),"""", VLOOKUP([@[Code Frns]]," & matrice & ",5,FALSE))"