deleting worksheets instead of hiding

armesca

Registered User.
Local time
Today, 18:04
Joined
Apr 1, 2011
Messages
45
This code works perfectly when I hide the sheets that are empty, when I try to delete them, the code runs but none of the sheets get deleted. Any thoughts??

Dim varSplit As Variant
Dim iwsCount As Integer
Dim iwsRangeCount As Integer
Dim blnallempty As Boolean
Dim z As Integer

varSplit = Split("A5,A18,A49,A64,A77,A115,A130,A143,A177,A192,A205,A249", ",")

For z = 1 To objwb.Worksheets.Count
'MsgBox objwb.Worksheets.Count
For iwsRangeCount = 0 To UBound(varSplit)
If IsEmpty(Sheets(z).Range(varSplit(iwsRangeCount))) Then
blnallempty = True
Else
blnallempty = False
Exit For
End If
Next
If blnallempty = True Then
'MsgBox objws.Name
objwb.Sheets(z).Visible = xlVeryHidden
'ActiveSheet.Delete
End If
Next z
 
Well the delete code is commented out...

But assuming that you actually remove the comment mark ', the reason your sheets aren't getting deleted is because you're using the ActiveSheet property, change that to the same method as the previous line (objwb.Sheets(z).Delete)
 

Users who are viewing this thread

Back
Top Bottom