ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting sheets (https://www.excelbanter.com/excel-programming/436821-deleting-sheets.html)

Oldjay

Deleting sheets
 
I want a command button that deletes all sheets except the one named Master

Jacob Skaria

Deleting sheets
 
Try the below

Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In Sheets
If ws.Name < "Master" Then ws.Delete
Next
Application.DisplayAlerts = True

--
Jacob


"oldjay" wrote:

I want a command button that deletes all sheets except the one named Master


Oldjay

Deleting sheets
 
Thanks

"Jacob Skaria" wrote:

Try the below

Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In Sheets
If ws.Name < "Master" Then ws.Delete
Next
Application.DisplayAlerts = True

--
Jacob


"oldjay" wrote:

I want a command button that deletes all sheets except the one named Master



All times are GMT +1. The time now is 03:47 AM.

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