IF Statements Part 2- IF THEN ELSE Structure

Excel VBA for Beginners 8- Must know Excel Logic
3 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€84.96
List Price:  €118.95
You save:  €33.99
£72.96
List Price:  £102.15
You save:  £29.18
CA$136.44
List Price:  CA$191.02
You save:  CA$54.58
A$152.31
List Price:  A$213.25
You save:  A$60.93
S$127.35
List Price:  S$178.29
You save:  S$50.94
HK$784.90
List Price:  HK$1,098.89
You save:  HK$313.99
CHF 79.24
List Price:  CHF 110.93
You save:  CHF 31.69
NOK kr1,008.97
List Price:  NOK kr1,412.61
You save:  NOK kr403.63
DKK kr633.97
List Price:  DKK kr887.58
You save:  DKK kr253.61
NZ$164.65
List Price:  NZ$230.51
You save:  NZ$65.86
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.91
৳12,275.24
List Price:  ৳17,185.83
You save:  ৳4,910.59
₹8,566.19
List Price:  ₹11,993.01
You save:  ₹3,426.81
RM422.85
List Price:  RM592.01
You save:  RM169.16
₦153,435.65
List Price:  ₦214,816.05
You save:  ₦61,380.40
₨28,380.62
List Price:  ₨39,734
You save:  ₨11,353.38
฿3,241.97
List Price:  ฿4,538.89
You save:  ฿1,296.92
₺3,979.26
List Price:  ₺5,571.12
You save:  ₺1,591.86
B$548.17
List Price:  B$767.46
You save:  B$219.29
R1,765.99
List Price:  R2,472.46
You save:  R706.46
Лв166.12
List Price:  Лв232.58
You save:  Лв66.45
₩135,896.76
List Price:  ₩190,260.91
You save:  ₩54,364.14
₪337.10
List Price:  ₪471.96
You save:  ₪134.85
₱5,636.93
List Price:  ₱7,891.93
You save:  ₱2,255
¥14,390.85
List Price:  ¥20,147.76
You save:  ¥5,756.91
MX$1,873.20
List Price:  MX$2,622.56
You save:  MX$749.35
QR363.67
List Price:  QR509.15
You save:  QR145.48
P1,323.02
List Price:  P1,852.29
You save:  P529.26
KSh12,918.70
List Price:  KSh18,086.70
You save:  KSh5,168
E£4,930.31
List Price:  E£6,902.64
You save:  E£1,972.32
ብር13,781.55
List Price:  ብር19,294.72
You save:  ብር5,513.17
Kz91,522.68
List Price:  Kz128,135.41
You save:  Kz36,612.73
CLP$92,853.71
List Price:  CLP$129,998.91
You save:  CLP$37,145.20
CN¥716.79
List Price:  CN¥1,003.54
You save:  CN¥286.74
RD$5,947.04
List Price:  RD$8,326.09
You save:  RD$2,379.05
DA12,977.24
List Price:  DA18,168.65
You save:  DA5,191.41
FJ$223.59
List Price:  FJ$313.04
You save:  FJ$89.44
Q769.15
List Price:  Q1,076.85
You save:  Q307.69
GY$20,917.70
List Price:  GY$29,285.62
You save:  GY$8,367.91
ISK kr12,150.78
List Price:  ISK kr17,011.58
You save:  ISK kr4,860.80
DH897.69
List Price:  DH1,256.80
You save:  DH359.11
L1,680.37
List Price:  L2,352.58
You save:  L672.21
ден5,224.55
List Price:  ден7,314.58
You save:  ден2,090.03
MOP$808.74
List Price:  MOP$1,132.27
You save:  MOP$323.53
N$1,758.42
List Price:  N$2,461.86
You save:  N$703.44
C$3,681.01
List Price:  C$5,153.57
You save:  C$1,472.55
रु13,679.29
List Price:  रु19,151.56
You save:  रु5,472.26
S/354.32
List Price:  S/496.07
You save:  S/141.74
K412.47
List Price:  K577.48
You save:  K165
SAR374.98
List Price:  SAR524.98
You save:  SAR150
ZK2,387.95
List Price:  ZK3,343.22
You save:  ZK955.27
L430.46
List Price:  L602.67
You save:  L172.20
Kč2,093.79
List Price:  Kč2,931.39
You save:  Kč837.60
Ft33,882.61
List Price:  Ft47,437.01
You save:  Ft13,554.40
SEK kr951.44
List Price:  SEK kr1,332.05
You save:  SEK kr380.61
ARS$120,587.94
List Price:  ARS$168,827.94
You save:  ARS$48,240
Bs691.16
List Price:  Bs967.65
You save:  Bs276.49
COP$411,525.38
List Price:  COP$576,152
You save:  COP$164,626.61
₡50,485.92
List Price:  ₡70,682.31
You save:  ₡20,196.38
L2,613.88
List Price:  L3,659.54
You save:  L1,045.65
₲797,842.75
List Price:  ₲1,117,011.76
You save:  ₲319,169.01
$U3,996.09
List Price:  $U5,594.69
You save:  $U1,598.59
zł361.30
List Price:  zł505.84
You save:  zł144.53
Already have an account? Log In

Transcript

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

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.