View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Case not recognized in Select Case

On Mon, 29 Mar 2010 08:52:02 -0700, kevlarmcc
wrote:

I am using Select Case in a macro that deletes worksheets to skip
specifically named worksheets. Code is:

For Each Worksheet In Worksheets
Select Case Worksheet.name
Case "Sheet1", 'Sheet2", "Sheet3", etc.

Case Else

Worksheet.Activate
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True


End Select
Next Worksheet

The problem is I have a worksheet named "BGE" that I want skipped and the
select case is not recognizing it and deletes it. I wonder if this has to do
with Excel 2k7 using BGE as a cell value. Any ideas?


BGE is not in your Case statement; so when Worksheet.Name = BGE, the case else
code will get executed, and the sheet will be deleted.
--ron