define "empty"
you must keep at least one sheet
Sub RemoveEmptySheets()
Dim ws As Worksheet
On Error Resume Next
Application.DisplayAlerts = False
For Each ws In Worksheets
If ws.UsedRange.SpecialCells
(xlCellTypeLastCell).Address = "$A$1" Then
ws.Delete
End If
Next
Application.DisplayAlerts = True
End Sub
Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
Hi.
From a macro, I want to delete all worksheets in a
workbook that are
empty. With the expression
ActiveSheet.Delete (supposed I activate each sheet one
after
another)
this happens. Problem here is that I will be asked
whether I really
wanted to delete the sheet through a message box. Is
there away to turn
this off?
Thanks
F
---
Message posted from http://www.ExcelForum.com/
.