ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to delete worksheet with specific criteria (https://www.excelbanter.com/excel-programming/333322-how-delete-worksheet-specific-criteria.html)

Angus

How to delete worksheet with specific criteria
 
Hi expert,

I am looking for a VBA code with following purpose:

Delete worksheets with column grand of pivot table (pivot table name
unknown) = 0 AND worksheet name contain "@"?

Angus

How to delete worksheet with specific criteria
 
What if I want to delete worksheet with worksheet name "@" AND contain no
number in column A (but will have text)? I use following code but doesn't
work.

Sub DeleteBlankSheet()
For Each ws In ThisWorkbook.Worksheets
If (InStr(ws.Name, "@") 0 And IsNumeric(ws.Range("A:A")) = False)
Then
Application.DisplayAlerts = False
ws.Delete
Else
Cells.EntireColumn.AutoFit
Application.DisplayAlerts = True
End If
Next ws
End Sub

"Angus" wrote:

Hi expert,

I am looking for a VBA code with following purpose:

Delete worksheets with column grand of pivot table (pivot table name
unknown) = 0 AND worksheet name contain "@"?



All times are GMT +1. The time now is 09:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com