ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete All Sheets Except "X" and "Y" (https://www.excelbanter.com/excel-programming/381086-re-delete-all-sheets-except-x-y.html)

Ron de Bruin

Delete All Sheets Except "X" and "Y"
 
Try this

If Sht.Name = "Tickers" Or Sht.Name = "AllCos" Then
' Do nothing
Else
Sht.Delete
End If


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SteveC" wrote in message ...
The following is a piece from a macro which works:

For Each Sht In Sheets ' delete all sheets with previous results firstly
If Sht.Name < "Tickers" Then
Sht.Delete

I modified it to this, but it doesn't work:
If Sht.Name < "Tickers" or "AllCos" Then
Sht.Delete

how do I modify it so the macro doesn't delete the sheets named Tickers and
AllCos

Thanks very much.

SteveC



All times are GMT +1. The time now is 04:24 AM.

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