View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
tercerojista tercerojista is offline
external usenet poster
 
Posts: 5
Default Why isn't my error handling working?!

On Mar 29, 1:41 pm, "tercerojista"
wrote:
NickHK, thank you very much: that's the sort of elegant solution I
like - I didn't know about the IsDate function. Everything works fine
now.

I'm still in the dark as to why the error handler wasn't handling the
error that was arising, though...

On Mar 29, 11:43 am, "NickHK" wrote:



Why not simplify the logic and test with IsDate ?


Dim DateStr as string


DateStr=Mid(strThisText, 4, 2) & "/" & Left(strThisText, 2) & "/" &
Mid(strThisText, 7, 4))
if IsDate(DateStr) then
.....


Then you do not need to jump around.


NickHK
- Show quoted text -- Hide quoted text -


- Show quoted text -


I am actually now really curious about error handling - I've put
together another bit of code that doesn't seem to take heed of the
error handling every time. I've searched around and can't find any
documentation regarding error handling not working, yet I can
definitely put together code for which error handling will simply not
kick in...

Does anyone out there have any information regarding why error
handling may choose not to work sometimes?!

The two cases I have now a
1. The case explained in this thread, when a value that is not a date
value is passed to Excel as if it were a date value (ie the date value
is invalid)
2. An attempt is made to insert an invalid formula into a cell

In both cases, an error is raised, and I'm baffled as to why these
particular errors aren't picked up by the error handler. Other errors
are picked up by the code.