On Error resume Next

Excel VBA for Beginners 11- Error Handling
2 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
€86.17
List Price:  €120.64
You save:  €34.47
£73.49
List Price:  £102.89
You save:  £29.40
CA$137.32
List Price:  CA$192.26
You save:  CA$54.93
A$153.93
List Price:  A$215.51
You save:  A$61.58
S$128.06
List Price:  S$179.29
You save:  S$51.23
HK$784.91
List Price:  HK$1,098.91
You save:  HK$313.99
CHF 80.65
List Price:  CHF 112.91
You save:  CHF 32.26
NOK kr1,014.98
List Price:  NOK kr1,421.02
You save:  NOK kr406.03
DKK kr642.88
List Price:  DKK kr900.05
You save:  DKK kr257.17
NZ$166.09
List Price:  NZ$232.54
You save:  NZ$66.44
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,220.91
List Price:  ৳17,109.77
You save:  ৳4,888.85
₹8,608.09
List Price:  ₹12,051.67
You save:  ₹3,443.58
RM423.69
List Price:  RM593.19
You save:  RM169.49
₦155,048.49
List Price:  ₦217,074.09
You save:  ₦62,025.60
₨28,367.16
List Price:  ₨39,715.16
You save:  ₨11,348
฿3,263.32
List Price:  ฿4,568.78
You save:  ฿1,305.46
₺3,974.68
List Price:  ₺5,564.71
You save:  ₺1,590.03
B$551.25
List Price:  B$771.77
You save:  B$220.52
R1,777.21
List Price:  R2,488.17
You save:  R710.95
Лв168.51
List Price:  Лв235.92
You save:  Лв67.41
₩136,299.66
List Price:  ₩190,824.98
You save:  ₩54,525.31
₪340.89
List Price:  ₪477.26
You save:  ₪136.37
₱5,675.40
List Price:  ₱7,945.79
You save:  ₱2,270.38
¥14,572.02
List Price:  ¥20,401.41
You save:  ¥5,829.39
MX$1,898.30
List Price:  MX$2,657.69
You save:  MX$759.39
QR364.02
List Price:  QR509.64
You save:  QR145.62
P1,331.45
List Price:  P1,864.09
You save:  P532.63
KSh12,923.70
List Price:  KSh18,093.70
You save:  KSh5,170
E£4,989.79
List Price:  E£6,985.90
You save:  E£1,996.11
ብር13,483.65
List Price:  ብር18,877.65
You save:  ብር5,394
Kz91,186.38
List Price:  Kz127,664.58
You save:  Kz36,478.20
CLP$93,584.64
List Price:  CLP$131,022.24
You save:  CLP$37,437.60
CN¥717.30
List Price:  CN¥1,004.26
You save:  CN¥286.95
RD$5,925.87
List Price:  RD$8,296.46
You save:  RD$2,370.58
DA12,977.52
List Price:  DA18,169.05
You save:  DA5,191.52
FJ$224.95
List Price:  FJ$314.94
You save:  FJ$89.99
Q768.42
List Price:  Q1,075.83
You save:  Q307.40
GY$20,906.39
List Price:  GY$29,269.79
You save:  GY$8,363.39
ISK kr12,252.77
List Price:  ISK kr17,154.37
You save:  ISK kr4,901.60
DH911.13
List Price:  DH1,275.62
You save:  DH364.49
L1,703.85
List Price:  L2,385.46
You save:  L681.60
ден5,301.31
List Price:  ден7,422.05
You save:  ден2,120.73
MOP$807.99
List Price:  MOP$1,131.22
You save:  MOP$323.22
N$1,787.32
List Price:  N$2,502.32
You save:  N$715
C$3,674.63
List Price:  C$5,144.63
You save:  C$1,470
रु13,750.25
List Price:  रु19,250.91
You save:  रु5,500.65
S/358.96
List Price:  S/502.56
You save:  S/143.60
K410.95
List Price:  K575.35
You save:  K164.40
SAR374.98
List Price:  SAR524.99
You save:  SAR150.01
ZK2,339.27
List Price:  ZK3,275.07
You save:  ZK935.80
L435.69
List Price:  L609.99
You save:  L174.29
Kč2,133.89
List Price:  Kč2,987.54
You save:  Kč853.64
Ft34,568.41
List Price:  Ft48,397.16
You save:  Ft13,828.75
SEK kr951.96
List Price:  SEK kr1,332.79
You save:  SEK kr380.82
ARS$117,386.24
List Price:  ARS$164,345.43
You save:  ARS$46,959.19
Bs692.01
List Price:  Bs968.84
You save:  Bs276.83
COP$409,127.94
List Price:  COP$572,795.49
You save:  COP$163,667.54
₡50,580.96
List Price:  ₡70,815.37
You save:  ₡20,234.40
L2,615.73
List Price:  L3,662.13
You save:  L1,046.40
₲797,718.74
List Price:  ₲1,116,838.15
You save:  ₲319,119.41
$U4,041.43
List Price:  $U5,658.16
You save:  $U1,616.73
zł366.13
List Price:  zł512.59
You save:  zł146.46
Already have an account? Log In

Transcript

Okay, guys, so now we're going to introduce a very important statement that you're going to use a lot when handling errors, which is the on error statement. Okay, so let's say I've written this line of code here, worksheets, my worksheet does select, and actually, there isn't a worksheet that is called my worksheet in this workbook. So if you run that, you will get a runtime error. So straight out of range. So I'll press enter here and try to deal with my error. The simplest form of dealing with that error is to write on error resume next, saw an error resume.

Next, what it does is that it just simply ignores the error. So this statement is going to cause an error. We'll just ignore it and execute anything after it. So maybe message box, we have ignored the error. And if we just execute that, let's do it step by step actually. So on our zoom next year, And so now any statement is going to cause an error that is going to come after on error resume next the error is just gonna be ignored Okay, and please note that it is going to be for any statement that would cause an error not just this statement here worksheets my worksheet does select any statement that will cause error from now on after executing the on error resume next line of code is going to be ignored.

So now worksheets my worksheet select this school is an error but it actually is going to be ignored and then we'll execute this message box and that's it. Okay, so here the the macro ends. And so if we write actually another statement that would cause an error, so my worksheets, another worksheet, I'm just going to call it another worksheet dot select. So this one as well should cause an error but because as part of our macro execute this statement here on error resume next, this is going to affect this statement or it's going to be ignored and this statement as well. error is going to be one word and then we're going to get our message box. Well, that's a very easy way to ignore errors, but you're just ignoring them.

You're not handling them. You're not creating a workaround or a solution for the error. Okay, but this is the simplest form. Sometimes you're going to use it is the simplest thing that you can do. There are more sophisticated or more complex stuff that you can do on handling errors.

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.