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.
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.
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 300 handy functions, makes your jobs more easier.|
After free installing Kutools for Excel, please do as below:
1. Enable the workbook you want to remove its empty sheets, and click Kutools Plus > Worksheet > Delete Blank Worksheets. See screenshot:
- 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?