Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function Error IF Statement Bob Zimmerman Excel Worksheet Functions 3 May 12th 10 01:46 PM
If Statement Error Kiley Excel Discussion (Misc queries) 3 May 18th 09 10:25 PM
If statement error check lghovden06 Excel Worksheet Functions 1 July 9th 08 11:05 PM
Can't fix On Error statement austris Excel Discussion (Misc queries) 7 October 13th 06 07:09 AM
IF statement error D Excel Discussion (Misc queries) 4 October 4th 06 04:28 PM


All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"