- Tham gia
- 9/10/06
- Bài viết
- 180
- Được thích
- 185
Option Explicit
Sub DeleteBlankSheets()
Dim sh As Variant
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Goto Exits:
For Each sh In Sheets
If Not IsChart(sh) Then
If Application.WorksheetFunction.CountA(sh.Cells) = 0 Then sh.Delete
End If
Next sh
Exits:
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Public Function IsChart(sh) As Boolean
Dim tmpChart As Chart
On Error Resume Next
Set tmpChart = Charts(sh.Name)
IsChart = IIf(tmpChart Is Nothing, False, True)
End Function
Sub DeleteBlankSheets()
Dim sh As Variant
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Goto Exits:
For Each sh In Sheets
If Not IsChart(sh) Then
If Application.WorksheetFunction.CountA(sh.Cells) = 0 Then sh.Delete
End If
Next sh
Exits:
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Public Function IsChart(sh) As Boolean
Dim tmpChart As Chart
On Error Resume Next
Set tmpChart = Charts(sh.Name)
IsChart = IIf(tmpChart Is Nothing, False, True)
End Function