Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Background:
I have been learning to use error handling when coding macros - mostly just using On Error GoTo statements. I have a subroutine that is called from an OnError GoTo block. If a certain condition is met (no files were found that fit my criteria), I want my subroutine to throw an error and return to the function that called it. This is not a situation that will normally throw an error, but I need to handle it as if it were an error. Question: How do I throw an error? (short of simply putting in a non-valid statement that I know will cause a real error) -- Message posted via http://www.officekb.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just add the line
Error 1 Which raises the application defined or object defined error. For different errors just use the appropriate error number/code. -- HTH... Jim Thomlinson "Sarah B via OfficeKB.com" wrote: Background: I have been learning to use error handling when coding macros - mostly just using On Error GoTo statements. I have a subroutine that is called from an OnError GoTo block. If a certain condition is met (no files were found that fit my criteria), I want my subroutine to throw an error and return to the function that called it. This is not a situation that will normally throw an error, but I need to handle it as if it were an error. Question: How do I throw an error? (short of simply putting in a non-valid statement that I know will cause a real error) -- Message posted via http://www.officekb.com |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks! I've had to rearrange my code and now I don't need to purposely throw
an error. But I will keep this command handy just in case. -- Message posted via http://www.officekb.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Paste Special throwing an error | Excel Discussion (Misc queries) | |||
copy and insert throwing error- help in code req | Excel Discussion (Misc queries) | |||
aconcat UDF throwing a #NAME error | Excel Worksheet Functions | |||
Formulas bug or on purpose | Excel Discussion (Misc queries) | |||
Throwing Out top & lower percentages | Excel Worksheet Functions |