Reputation: 11
I would like to use if function in vba with loop, so a i have a code like below
Worksheets("Teszt_dec").Cells(i, j + oszlop_number + 5).Formula = "=IIf(Teszt!" & Worksheets("Teszt_dec").Cells(i, j + oszlop_number + 5).address(False, False) & "<$F22,1,0)"
and i got these message:
(that means #name error just in hungarian)
And if i select the cells, and press enter the error message suddenly disappear and works fine....
So anyone have any idea how can i solve this problem?
Upvotes: 0
Views: 97
Reputation: 43565
Iif
is a VBA function. In your case, you are in need of an Excel formula, because you are calling like this:
Worksheets("Teszt_dec").Cells(i, j + oszlop_number + 5).Formula
The Excel formula is =IF
.
Thus try with Cells(1,1).Formula = "=IF(condition,true,false)"
Upvotes: 1