Get a month of TabletWise Pro for free! Click here to redeem

IF Statements Part 2- IF THEN ELSE Structure

3 minutes
Share the link to this page
You need to purchase the class to view this lesson.
One-time Purchase
List Price:  $139.99
You save:  $40
List Price:  د.إ514.18
You save:  د.إ146.92
List Price:  A$200.99
You save:  A$57.43
List Price:  ৳11,866.71
You save:  ৳3,390.73
List Price:  CA$190.20
You save:  CA$54.34
CHF 94.14
List Price:  CHF 131.80
You save:  CHF 37.66
List Price:  kr923.82
You save:  kr263.96
List Price:  €123.99
You save:  €35.42
List Price:  £111.45
You save:  £31.84
List Price:  HK$1,084.93
You save:  HK$310
List Price:  ₹10,477.20
You save:  ₹2,993.70
List Price:  RM598.38
You save:  RM170.98
List Price:  ₦54,246.12
You save:  ₦15,500
List Price:  kr1,324.07
You save:  kr378.33
List Price:  NZ$213.40
You save:  NZ$60.97
List Price:  ₱6,939.32
You save:  ₱1,982.80
List Price:  ₨23,350.33
You save:  ₨6,672
List Price:  S$195.06
You save:  S$55.73
List Price:  ฿4,367.55
You save:  ฿1,247.96
List Price:  ₺959.76
You save:  ₺274.23
List Price:  R2,396.08
You save:  R684.64
Already have an account? Log In


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.

Sign Up