ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error does not appear to get directed to the OnError code. (https://www.excelbanter.com/excel-programming/429553-error-does-not-appear-get-directed-onerror-code.html)

AC

Error does not appear to get directed to the OnError code.
 
Hi

We are having a problem with error trapping in Excel.

We have code which says On Error goto xyz, which looks for a specific
error and deals with it. It then returns back to the code where it
trapped the error.

We expect to see this error multiple times in the code execution. The
code being used is something like:

set myCell = Cells(i,j)

on error goto xyz
sMyString = myCell.Formula


Not all cells have formulas and so it throws an error sometimes, and
that's fine by us [we are trying to find the cells with formulas]

The first time it throws an error on the sMyString line it correctly
goes to our error label xyz and then gets returned back into the
loop. However the 2nd time it throws an error it pops up the error
box rather than jumping to the error handling code again.


Can someone shed some light?

Thanks
Andy C


All times are GMT +1. The time now is 06:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com