Hi,
I've been successfully able to delete all excel tabs where there are 0 rows of data in it using the code below:
Sub DelMT()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In ActiveWorkbook.Worksheets
If Application.CountA(ws.Cells) = 0 Then ws.Delete
Next ws
Application.DisplayAlerts = True
End Sub
However, I like to delete all tabs where there is less than 1 row. i.e. If you have only 1 or more cells in the first row of a given sheet that sheet will be deleted.
If you have two or more rows, that sheet would not get deleted.
What changes are required to the above code?
I've been successfully able to delete all excel tabs where there are 0 rows of data in it using the code below:
Sub DelMT()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In ActiveWorkbook.Worksheets
If Application.CountA(ws.Cells) = 0 Then ws.Delete
Next ws
Application.DisplayAlerts = True
End Sub
However, I like to delete all tabs where there is less than 1 row. i.e. If you have only 1 or more cells in the first row of a given sheet that sheet will be deleted.
If you have two or more rows, that sheet would not get deleted.
What changes are required to the above code?