Used with ELSE, ELSE.IF, and END.IF to control which formulas in a macro are executed. There are two syntax forms of the IF function. The following syntax can be used on macro sheets only; use it when you want your macro to branch to a particular set of functions based on the outcome of a logical test. The worksheet form of this function can be used on worksheets and macro sheets.
Syntax
IF(logical_test)
Logical_test is a logical value that IF uses to determine which functions to carry out next—that is, where to branch.
If logical_test is TRUE, Microsoft Excel carries out the functions between the IF function and the next ELSE, ELSE.IF, or END.IF function. Instructions between ELSE.IF or ELSE and END.IF are not carried out.
If logical_test is FALSE, Microsoft Excel immediately branches to the next ELSE.IF, ELSE, or END.IF function.
If logical_test produces an error, the macro halts.