The VBA IFF function is listed under the logical category of VBA functions. When you use it in a VBA code, it evaluates the value supplied for a condition and returns a value is the condition is TRUE else the other value if that condition is FALSE. It’s just like the IF function in the worksheet.
Syntax
IIf(Expression, TruePart, FalsePart)
Arguments
- Expression: The condition which you want to test.
- TruePart: The value to return if “Expression” is TRUE.
- FalsePart: The value to return if “Expression” is FALSE.
It’s better to use VBA IF statement instead of IIF as it makes code hard to read.