?
Solved

Delete Empty Worksheets

Posted on 2011-09-05
2
Medium Priority
?
264 Views
Last Modified: 2012-05-12

Need to delete all worksheets in workbook that have no data.
0
Comment
Question by:mato01
2 Comments
 
LVL 11

Expert Comment

by:Plantwiz
ID: 36484753
Highlight the worsheet tab, right click, delete

Or is there more information you are able to provide regarding your initial question?
0
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 36484890
Here is a macro to delete the empty worksheets. Install it in a regular module sheet.
Sub DeleteEmptySheets()
Dim ws As Worksheet
Dim rg As Range
On Error Resume Next
Application.DisplayAlerts = False
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
    Set rg = ws.UsedRange
    If (rg.Cells.Count = 1) And (rg.Cells(1, 1) = "") Then ws.Delete
Next
Application.DisplayAlerts = True
End Sub

Open in new window


Brad
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a serious pitfall that can happen when deleting shapes using VBA.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question