Sub test()
Application.DisplayAlerts = False
For Each wks In Worksheets
if wks.name<>"Profiles" then ws.delete
Next wks
Application.DisplayAlerts = true
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"El Bee" <(E-Mail Removed)> wrote in message
news:4B4D29D4-EDDF-4C5E-A0A0-(E-Mail Removed)...
>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.