Free Excel VBA Course #22 - Error Handling in VBA (On Error Goto/Resume)

preview_player
Показать описание
In this video, I will show you how to handle errors in VBA in Excel.

VBA has given us some tools and techniques you can use to handle errors and In some cases use these to your advantage.

There are statements such as On Error Goto or On Error Resume where you can specify what to do in case VBA encounters an error. You can ask the code to jump to a specific line of code or you can ask it to ignore the error and keep moving.

You can also use message boxes to identify and understand the errors better.

#Excel #ExcelTips #ExcelTutorial
Рекомендации по теме
Комментарии
Автор

This is amazing. Has saved me so much pain. Thank you so much

douglashaffner
Автор

how to exit the loop? I have no idea. Eventually i had to end the task via taskmanager. Any feedback is highly appreciated.

kaustubhzende
Автор

can i handle "runtime error 4605" with this method?

ardhik
Автор

Can you help me what i am missing out in this code? after debugging showing run time error 13 "Number = InputBox("Enter numeric value")" area

Sub errorhandling()
Dim Number As Long
On Error GoTo EntryError

Number = InputBox("Enter numeric value")
Range("A1").Value = Number

EntryError:
MsgBox "Please enter valid value"

End Sub

surajrawat
Автор

In the following, when i run it, it takes alphanumeric value, numeric value, integer value. It didn't show error.
Can anyone give me what I have done wrong?

Sub ErrorHandling()

Dim Emp_Name As String

EName:
On Error GoTo NameError
Emp_Name = InputBox("Please Enter Employee Name")
Range("b2") = Emp_Name
Exit Sub

NameError:
MsgBox "Please Enter Numeric Value Only"
Resume EName

End Sub

umamaheshk
visit shbcf.ru