The Immediate If Function
The Immediate If function has the syntax:
IIf(Expression, TruePart, FalsePart)
If Expression is True, then the function returns TruePart. If Expression is False, the
function returns FalsePart. For instance, the following code displays a dialog indicating
whether or not the first row in the active worksheet is empty:
It is very important to note that the Immediate If function always evaluates both TruePart andCode:Dim rng As Range Set rng = ActiveSheet.Rows(1) MsgBox IIf(IsEmpty(ActiveSheet.Cells(1, 1)), _ "Cell is empty", "Cell is not empty")
FalsePart, even though it returns only one of them. Hence, we must be careful about
undesirable side effects.




Reply With Quote
Bookmarks