ActiveSheet is blank

  • Thread starter Thread starter Stitch45
  • Start date Start date
S

Stitch45

What is the easiest way to check if the ActiveSheet isblank? I want to loop
through the sheets collection and delete all empty sheets.

thanks
 
This illustrates one way:

If Application.CountA(ActiveSheet.UsedRange) = 0 Then
MsgBox "Sheet is empty"
End If
 
for each sh in ActiveWorkbook.worksheets
if application.countA(sh.cells) = 0 then
Application.DisplayAlerts = False
sh.Delete
application.DisplayAlerts = True
end if
Next
 
Try this one
Sub Delete_EmptySheets()
Dim sh As Worksheet 'Ron de Bruin, programming, 2002-12-28
For Each sh In ThisWorkbook.Worksheets
If Application.WorksheetFunction.CountA(sh.Cells) = 0 Then
Application.DisplayAlerts = False
sh.Delete
Application.DisplayAlerts = True
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top