Hey guys, welcome back. So in this video, we're going to speak about the if then else statement. So we're going to kick our game a notch higher and add an else clause to the if statement. And the else clause basically marks the start of another set of code that is executed in case the condition is not true in case the condition is false, then the other set of code gets executed. So basically, the structure of the if then else statement is that if condition is equal to true, then execute code one. So this is the first set of code that is going to be executed in case that a condition is equal to true.
And of course, this code could be several lines of code. Basically, it shouldn't be just one line. And if the condition is false, it's actually gonna go straight away. Without any testing without any verification and just execute code to pay. So if the condition is false code two will be executed, no questions asked. And then we've got our end if that marks the end of the if statement.
Okay, so now we're going to have an example for the if then else statement. So we're actually going to have the same example here, as the one that we've had on the if statement is just that we've added some code to be executed in case of the else clause. So in case that this condition is false, which is active cell dot value is greater than or equal to sales target. In case that is false, what's after the else clause will be executed and it will be executed straightaway without any kind of verification. We're not going to test the condition or anything. It's just going to be executed.
No questions. Ask. So I've got here the sales amount for Jennifer for example selected. And now if I try to step through the code step by step by pressing f8 on my keyboard, you can see here that when we test the condition, actually, Jennifer is achieved the target, and the code that gets executed is the one that is associated with the condition being true. Now, if we take jack, for example, who has not achieved the target and tried to run the macro for jack, because here when we test the condition, active said that value is greater than or equal to sales target is going to be false. So it's going to go to the L straightaway, it won't test conditions or anything, it will just straightaway go execute.
The other message boxes says jack has not achieved the target. So that's basically it for the FN l statement, you add an else clause this else clause will have some code and This code will be executed straightaway if your condition is false it will be executed without any kind of testing. It will be just executed straight away. So that's it guys for the if then else statement on the upcoming videos we're going to expand more on the if statement. Thank you very much for watching this video and I'll see you on the next one.