View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
El Bee El Bee is offline
external usenet poster
 
Posts: 58
Default Deleting Worksheets

I have a workbook that contains 4 worksheets:
EcomSec, Programs, EcomData, & Profiles.

I do a lot of data manipulation between the EcomSec & EcomData ws and paste
that data into the Profiles ws.
After this completes I want to delete all but the Profiles ws. It was
working until one of the worksheets was moved.

Here's the code.
Sub test()
Application.DisplayAlerts = False
For Each wks In Worksheets
If InStr("Programs", wks.Name) 0 Then wks.Delete
If InStr("EcomSec", wks.Name) 0 Then wks.Delete
If InStr("EcomData", wks.Name) 0 Then wks.Delete
Next wks

End Sub

I know there's got to be a way to do this but not sure how.

Thanks for your help.