Murphander
New Member
- Joined
- Nov 29, 2016
- Messages
- 9
Hello - I wrote the following code to delete all empty sheets in a workbook (leaving one). I'm not an expert by any means, just wrote it the best way I knew how. Could you let me know if there is a better/more efficient way to do this?
If only blanks cells with no images/charts, then delete sheet.
Any thoughts?
Code:
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ActiveWorkbook.Sheets.count > 1 Then
If WorksheetFunction.CountA(ws.Cells) = 0 Then
If ws.Pictures.count = 0 And ws.ChartObjects.count = 0 Then
ws.Delete
End If
End If
End If
Next ws
If only blanks cells with no images/charts, then delete sheet.
Any thoughts?