ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   An error on the error :) (https://www.excelbanter.com/excel-programming/274984-re-error-error.html)

Trevor Shuttleworth

An error on the error :)
 
On Error Resume Next
Sheets("EMPLOYEE").Delete
Sheets("ALLSALES").Delete
On Error GoTo 0

Regards

Trevor


"Teggaman" wrote in message
om...
try this instead

On Error GoTo 777
Sheets("EMPLOYEE").Select
ActiveWindow.SelectedSheets.Delete
777:
On Error GoTo 0
on error goto end_error
end_error
Sheets("ALLSALES").Select
ActiveWindow.SelectedSheets.Delete
goto end_error

888:
resume 777

end_error:

end sub











"Paul" wrote in message

...
I want VB to delete two sheets if they exist.

In the following example, neither sheet exists. VB handles
the missing EMPLOYEE fine, but then crashes when it hits
the missing ALLSALES. Why?

On Error GoTo 777
Sheets("EMPLOYEE").Select
ActiveWindow.SelectedSheets.Delete
777:
On Error GoTo 0
On Error GoTo 888
Sheets("ALLSALES").Select
ActiveWindow.SelectedSheets.Delete
888:
On Error GoTo 0

TIA
Paul





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

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