Use of on error

jgoulart

Board Regular
Joined
Feb 16, 2002
Messages
62
What types of events or code would you put an on error in? I have an application that opens and closes another workbook, saves, and switches betweeen different sheets quite a bit. Is there somewhere I can go to find out more about "on error" and how to correctly use it?

John
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi

try the VBE help file ERRORS

Error Statement Example
This example uses the Error statement to simulate error number 11.

On Error Resume Next ' Defer error handling.
Error 11 ' Simulate the "Division by zero" error.

""""""""

Error Object, Errors Collection, and Description, Number, Source, HelpFile, and HelpContext Properties Example

This example forces an error, traps it, and displays the Description, Number, Source, HelpContext, and HelpFile properties of the resulting Error object.

Sub DescriptionX()

Dim dbsTest As Database

On Error GoTo ErrorHandler

' Intentionally trigger an error.
Set dbsTest = OpenDatabase("NoDatabase")

Exit Sub

ErrorHandler:
Dim strError As String
Dim errLoop As Error

' Enumerate Errors collection and display properties of
' each Error object.
For Each errLoop In Errors
With errLoop
strError = _
"Error #" & .Number & vbCr
strError = strError & _
" " & .Description & vbCr
strError = strError & _
" (Source: " & .Source & ")" & vbCr
strError = strError & _
"Press F1 to see topic " & .HelpContext & vbCr
strError = strError & _
" in the file " & .HelpFile & "."
End With
MsgBox strError
Next

Resume Next

End Sub

::::::::::

that sort of thing what you looking for?
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,684
Members
448,977
Latest member
dbonilla0331

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top