Finally, if all the IF and ELSEIF’s evaluate to FALSE then the ELSE block will be executed. However, in case, it also evaluates to FALSE then the next ELSEIF statement will be evaluated and so on. If it evaluates to TRUE then the instructions inside the ELSEIF Block will be sequentially executed and the rest of the blocks (ELSEIF’s and ELSE blocks) will be skipped. This means, first of all, the IF Statement with ‘ condition_1’ will be evaluated, if it evaluates to TRUE then statements inside the first IF block will be executed and the rest of the blocks (ELSEIF’s and ELSE blocks) will be skipped.īut, if the First IF Statement evaluates to FALSE then the ELSEIF statement following it will be evaluated. The conditions along with the IF Statements will be evaluated sequentially. IF function usually ends with an ‘ END IF’ statement which tells the application that it is the last line of the IF function. The ‘ THEN’ keyword is basically a directive signifying that the instructions immediately following the IF Statement are to be executed if the condition evaluates to TRUE. either it should be TRUE or it should be FALSE). Here, ‘ condition_1’ to ‘ condition_n’ refers to the expression that must evaluate to a Boolean value (i.e. Recommended Reading: Nested IF’s in Excel In such a case, if the condition inside IF statement evaluates to FALSE then the program control just moves to the next instruction (the instruction after the IF Block) and starts executing them sequentially. However, if the condition evaluates to FALSE then it takes the program control to the statements inside the Else Block.Īlthough, it is not mandatory to have an Else Block with every IF statement. If the condition evaluates to TRUE then, it simply takes the program control to the instructions inside the IF block and starts executing them sequentially. On the other hand, VBA IF Statement checks a condition but it doesn’t return any value. The IF Function in Excel and the IF Statement in VBA are basically designed to do the same tasks, but the way they work is slightly different from each other.Įxcel IF function checks a particular condition and if the condition is TRUE, it returns one value otherwise it returns the second value. If you have followed my earlier posts, then you would remember that we discussed If Function in Excel. The task of the IF Statement is to check if a particular condition is met or not. IF statement in VBA is sometimes also called as IF THEN ELSE Statement. ![]() ![]() IF is one of the most popular and frequently used statements in VBA.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |