ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ActiveSheet is blank (https://www.excelbanter.com/excel-programming/321940-activesheet-blank.html)

Stitch45

ActiveSheet is blank
 
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



Jim Rech

ActiveSheet is blank
 
This illustrates one way:

If Application.CountA(ActiveSheet.UsedRange) = 0 Then
MsgBox "Sheet is empty"
End If


--
Jim Rech
Excel MVP
"Stitch45" wrote in message
...
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




Tom Ogilvy

ActiveSheet is blank
 
for each sh in ActiveWorkbook.worksheets
if application.countA(sh.cells) = 0 then
Application.DisplayAlerts = False
sh.Delete
application.DisplayAlerts = True
end if
Next



--
Regards,
Tom Ogilvy

"Stitch45" wrote in message
...
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





Ron de Bruin

ActiveSheet is blank
 
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

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Stitch45" wrote in message ...
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





All times are GMT +1. The time now is 03:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com