Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
On Error Statement
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Function Error IF Statement | Excel Worksheet Functions | |||
If Statement Error | Excel Discussion (Misc queries) | |||
If statement error check | Excel Worksheet Functions | |||
Can't fix On Error statement | Excel Discussion (Misc queries) | |||
IF statement error | Excel Discussion (Misc queries) |