![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 13
Rep Power: 0
![]() |
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
NextTIA. Picco |
|
|
|
|
|
#2 |
|
Expert Programmer
|
It works for me, it just raises an error when you get to the last sheet (you need at least one in a workbook!): normally when you get a method failed error in VBA it means something else has a lock on the object: where do you run this code?
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|