View Single Post
Old May 10th, 2005, 5:08 AM   #1
crmpicco
Newbie
 
Join Date: Feb 2005
Posts: 13
Rep Power: 0 crmpicco is on a distinguished road
Delete all empty worksheets: EXCEL VBA

I'm after code that can
Delete all empty worksheets.

I have this, but it doesnt work.

I get method 'delete' of object 'worksheet' failed.


Dim sh As Worksheet
    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


TIA.

Picco
crmpicco is offline   Reply With Quote