How to remove empty sheets from a workbooks
Supposing you have a large workbook with multiple sheets, but there are some empty sheets without any contents in this workbook. To make the workbook more professional and formal, you want to remove these blank sheets from the workbook. Instead of removing the empty sheets one by one, I introduce the methods to remove all blank sheets quickly.
Recommended Excel Productivity Tools
Here I introduce a VBA to help you quickly remove all blank sheets from an opened workbook.
1. Press Alt + F11 keys to enable Microsoft Visual for Basic Applications window.
2. And click Insert > Module, paste below VBA code to the new popped out Module window.
VBA: Remove empty sheets.
Sub DeletEmptySheets() 'UpdatebyKutoolsforExcel20151130 Dim xWs As Worksheet Dim xAlert As Boolean Dim xCount As Long xAlert = Application.DisplayAlerts Application.DisplayAlerts = False If MsgBox("Are you sure to remove all empty sheets?", vbYesNo, "Kutools for Excel") = vbNo Then Exit Sub For Each xWs In ActiveWorkbook.Worksheets If (Application.CountA(xWs.Cells) = 0) And _ (xWs.Shapes.Count = 0) Then xWs.Delete xCount = xCount + 1 End If Next MsgBox "You have removed " & xCount & " empty sheet(s)", , "Kutools for Excel" Application.DisplayAlerts = xAlert End Sub
3. And press F5 key or Run button to execute the VBA, and a dialog pops out to remind you whether to remove empty sheets, click Yes to go on removing, No to cancel this VBA.
4. After clicking Yes, a dialog pops out to tell you the number of removed sheets, click OK to close it, and all the empty sheets have been removed at this moment.
|Never need to worry about long long formulas in Excel anymore! Kutools for Excel's Auto Text can add all formulas to a group
as auto text, and liberate your brain! Know About Auto Text Get Free Trial
For some Excel green hands, the VBA is a somewhat difficult method to execute, but with Kutools for Excel’s Delete Blank Worksheets function, you can quickly remove all empty sheets from a workbook with three mouse-clicks!
|Kutools for Excel, with more than 120 handy Excel functions, enhance your working efficiency and save your working time.|
After free installing Kutools for Excel, please do as below:
1. Enable the workbook you want to remove its empty sheets, and click Enterprise > Worksheet > Delete Blank Worksheets. See screenshot:
2. And a Kutools for Excel dialog pops out to reconfirm that if you want to remove all blank sheets, and click Yes to continue removing, and No to cancel. See screenshot:
3. And after clicking Yes, a dialog pops out to remind you the number of successfully removed sheets. Click OK to close it.
- How to count and remove duplicates from a list in Excel?
- How to delete string after nth character in Excel?
- How to remove text within brackets/parentheses in Excel?
- How to remove line shapes in Excel?