Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I am trying to write a errandling routine. I have it working fine, but I would like add one thing. It would be nice to know where in the procedure the error occurred. Is there a way to get the procedure line number that caused the error? Thanks, Tony |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Saved from a post by Chip Pearson:
....A far better solution would be first to download MZTools (www.mztools.com) or a similar add-in that will automatically add line numbers to code. Then use On Error Goto <label to display the error. E.g., Sub AAA() Dim WS As Worksheet On Error GoTo ErrH: 10 Set WS = Worksheets("AAA") 20 Debug.Print "Error line skipped" 30 Exit Sub ErrH: 40 If MsgBox("Error on line: " & Erl & vbCrLf & _ "Error: " & CStr(Err.Number) & ": " & Err.Description & vbCrLf & _ "Do you want to continue?", vbYesNo) = vbYes Then 50 Resume Next ' optional. do you really want to 60 End If End Sub This will tell you exactly where the error occurred and you can change the code to prompt for a sheet name or workbook name or whatever is necessary to remedy the problem. You have the option of continuing the code execution if desired. Webtechie wrote: Hello, I am trying to write a errandling routine. I have it working fine, but I would like add one thing. It would be nice to know where in the procedure the error occurred. Is there a way to get the procedure line number that caused the error? Thanks, Tony -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sumproduct error caused by too many curly brackets? | Excel Worksheet Functions | |||
Error caused by *.xls file | Excel Discussion (Misc queries) | |||
Mysterious Error 1004 caused by AutoFilter? | Excel Programming | |||
Find Last Line Code: Let's Make This Better | Excel Programming | |||
Sharing Workbook caused error message | Excel Programming |