LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Delet Sheets with out Automation Error

here is my awesome code:

Option Private Module
Option Compare Binary
Option Explicit
Option Base 0

Public Const strDeleteSheet = "delSht"

Private Sub deleteSheets()

Dim xlSheet As Excel.Worksheet

Application.DisplayAlerts = False

For Each xlSheet In Application.ActiveWorkbook.Worksheets
If (xlSheet.CodeName Like strDeleteSheet & "*") Then
wkbActive.Worksheets(xlSheet.Name).Delete
End If
Next xlSheet

Application.DisplayAlerts = True

Set xlSheet = Nothing

End Sub

A not trappable error occurs: xlSheet.Name = <Automation error. The code
does not stop processing. I know this is due to changing the items in
ActiveWorkbook.Worksheets.

This error resets globally declared variables to empty/false/etc...

Any suggestions to delete sheets without resetting global variables?

Thank you.
rogge
 
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
Compile error: Automation error in Excel 97 Geoff Excel Programming 3 July 1st 08 07:20 AM
Urgent!!! Run-time error '-2147024770 (8007007e)' Automation error [email protected] Excel Programming 3 May 28th 08 04:51 AM
Delet certain row in a sheets in workbook Arne Hegefors Excel Programming 1 December 5th 07 08:52 AM
Run-Time Error'-2147221080(800401a8)': Automation Error BEEJAY Excel Programming 1 July 18th 06 03:13 PM
Unknown where is the problem on the Runtime error - Automation error wellie Excel Programming 1 July 10th 03 08:12 AM


All times are GMT +1. The time now is 08:45 AM.

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

About Us

"It's about Microsoft Excel"