Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Another Error Handling Question

I have a sub routine that may generate an error if a value is not defined.
While developing the code I've come accross the error and get an error
statement. I have to reset the code by selecting the reset button in the VBA
window to get it to work again. It's not a code issue but a data issue. I'm
not looking for a way to correct the data but I would like to use an error
handler to simply display a message and return the control back to the
spreadsheet so that the routine can run again without having to go to the
Debug window and resetting the code. Any suggestion?

Thank You,
--
Bernie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Another Error Handling Question

what do you mean by "not defined"? you can check issues and trap them in
your code. The fact that you get the debug window suggests that all you need
is to add a few
ON ERROR GOTO errorline
traps




"brichard429" wrote in message
...
I have a sub routine that may generate an error if a value is not defined.
While developing the code I've come accross the error and get an error
statement. I have to reset the code by selecting the reset button in the
VBA
window to get it to work again. It's not a code issue but a data issue.
I'm
not looking for a way to correct the data but I would like to use an error
handler to simply display a message and return the control back to the
spreadsheet so that the routine can run again without having to go to the
Debug window and resetting the code. Any suggestion?

Thank You,
--
Bernie


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Another Error Handling Question

Thank you Patrick for the reply. The error is a result of a "find" procedure
that has no results and therefore gives the "not defined" value. I wasn't
sure how to handle the particular error so I wanted to use the error check to
provide a message to the user and continue execution.
--
Bernie


"Patrick Molloy" wrote:

what do you mean by "not defined"? you can check issues and trap them in
your code. The fact that you get the debug window suggests that all you need
is to add a few
ON ERROR GOTO errorline
traps




"brichard429" wrote in message
...
I have a sub routine that may generate an error if a value is not defined.
While developing the code I've come accross the error and get an error
statement. I have to reset the code by selecting the reset button in the
VBA
window to get it to work again. It's not a code issue but a data issue.
I'm
not looking for a way to correct the data but I would like to use an error
handler to simply display a message and return the control back to the
spreadsheet so that the routine can run again without having to go to the
Debug window and resetting the code. Any suggestion?

Thank You,
--
Bernie


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Another Error Handling Question

Put this line at the beginning of the problem code segment:

On Error GoTo ErrHandler:

Then put this code near the end of the macro.

ErrHandler:
MsgBox "Error Number " & Err.Number & " Has Occurred. Restart Macro"
Err.Clear

This gives you the error number which you can evaluate before restarting.



"brichard429" wrote in message
...
I have a sub routine that may generate an error if a value is not defined.
While developing the code I've come accross the error and get an error
statement. I have to reset the code by selecting the reset button in the
VBA
window to get it to work again. It's not a code issue but a data issue.
I'm
not looking for a way to correct the data but I would like to use an error
handler to simply display a message and return the control back to the
spreadsheet so that the routine can run again without having to go to the
Debug window and resetting the code. Any suggestion?

Thank You,
--
Bernie



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Another Error Handling Question

Thank You, This is what I was looking for.
--
Bernie


"JLGWhiz" wrote:

Put this line at the beginning of the problem code segment:

On Error GoTo ErrHandler:

Then put this code near the end of the macro.

ErrHandler:
MsgBox "Error Number " & Err.Number & " Has Occurred. Restart Macro"
Err.Clear

This gives you the error number which you can evaluate before restarting.



"brichard429" wrote in message
...
I have a sub routine that may generate an error if a value is not defined.
While developing the code I've come accross the error and get an error
statement. I have to reset the code by selecting the reset button in the
VBA
window to get it to work again. It's not a code issue but a data issue.
I'm
not looking for a way to correct the data but I would like to use an error
handler to simply display a message and return the control back to the
spreadsheet so that the routine can run again without having to go to the
Debug window and resetting the code. Any suggestion?

Thank You,
--
Bernie



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
error handling question ADK Excel Programming 13 July 17th 07 04:00 PM
Error Handling question J@Y Excel Programming 3 June 22nd 07 06:16 PM
Error handling question sungen99[_115_] Excel Programming 0 June 6th 06 05:30 PM
Error Handling question BigPig Excel Programming 4 March 19th 06 08:00 PM
question error handling Pierre via OfficeKB.com[_2_] Excel Programming 3 November 7th 05 09:39 PM


All times are GMT +1. The time now is 06:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"