Home>Blogs>VBA>Delete all blank worksheet using Personal Macro
Delete all worksheet
VBA

Delete all blank worksheet using Personal Macro

In this article, we have create the a Personal Macro to delete all blank worksheet from active workbook. You can use this for the workbook wherein you have multiple worksheet and you want to delete the blank worksheet only. You can add a button on your excel ribbon to delete all blank worksheet from active workbook.

You can add below given code in your personal macro.

Option Explicit

Sub Delete_Blank_Worksheets()

Application.DisplayAlerts = False

Dim sh As Worksheet

For Each sh In ActiveWorkbook.Worksheets
   If Application.WorksheetFunction.CountA(sh.Cells) = 0 Then
      If ActiveWorkbook.Worksheets.Count > 1 Then
         sh.Delete
      End If
   End If
Next

MsgBox "Done"

End Sub

Watch the step by step video tutorial:

Click here to download this practice file.

PK
Meet PK, the founder of PK-AnExcelExpert.com! With over 15 years of experience in Data Visualization, Excel Automation, and dashboard creation. PK is a Microsoft Certified Professional who has a passion for all things in Excel. PK loves to explore new and innovative ways to use Excel and is always eager to share his knowledge with others. With an eye for detail and a commitment to excellence, PK has become a go-to expert in the world of Excel. Whether you're looking to create stunning visualizations or streamline your workflow with automation, PK has the skills and expertise to help you succeed. Join the many satisfied clients who have benefited from PK's services and see how he can take your Excel skills to the next level!
https://www.pk-anexcelexpert.com