View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Heapy Heapy is offline
external usenet poster
 
Posts: 14
Default On Error Statement

.... never mind. I guess a "Resume" statement is required to "clear" the
error; I tried putting one in and it worked.


"Heapy" wrote in message
...
Hi; I'm having some troubles with the ON...Error Statement.

In my example (below), I'm deleting a sheet, unless the sheet doesn't

exist
in which case I want an error handler to kick in which essentially skips

the
deletion section of my code and move on.

Problem is, when the sheet is not present, the error handler doesn't kick
in, and a run-time error occurs. Why? Is it because there's no Resume
statement anywhere within my code? I thought that if I explicity clear the
error with Err.Clear I wouldn't need a Resume statement, but (as usual)

I'm
probably missing something...

Does anyone have any suggestions as to what might be causing my error
handler to not kick in?

Thx
HWH

-------

On Error GoTo NOSHT1
Application.DisplayAlerts = False
Sheets(Grps(1, x) & "GRP").Delete
msgbox "Sheet Deleted"
... other stuff relating to the code that should only run if the sheet
is present


NOSHT1:
Application.DisplayAlerts = True
Err.Clear
On Error GoTo 0