ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting rows filled with 0 (https://www.excelbanter.com/excel-programming/284601-deleting-rows-filled-0-a.html)

Perry Kew

Deleting rows filled with 0
 
In Excel 2002 I have a sheet with data table from A1:E9.

The actual starts at B2 and ends at E9. If B:E of the same
row has zero I would like to delete that row. Thus if
cells in the range B3:E3 and cells in the range B8:E8 have
zeros then those rows should be deleted.

Thanks.



Bill Manville

Deleting rows filled with 0
 
Perry Kew wrote:
The actual starts at B2 and ends at E9. If B:E of the same
row has zero I would like to delete that row. Thus if
cells in the range B3:E3 and cells in the range B8:E8 have
zeros then those rows should be deleted.

With Range("A1:E9")
.AutoFilter
.AutoFilter 2,0
.AutoFilter 3,0
.AutoFilter 4,0
.AutoFilter 5,0
If .Columns(1).SpecialCells(xlVisible).Count1 Then
.Offset(1).Resize(.Rows.Count-1).SpecialCells(xlVisible).Delete _
Shift:=xlUp
End If
.AutoFilter
End With

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup


Perry

Deleting rows filled with 0
 
Thank you very much for your help Bill. This is what I
wanted and it has helped me out a lot.

-----Original Message-----
Perry Kew wrote:
The actual starts at B2 and ends at E9. If B:E of the

same
row has zero I would like to delete that row. Thus if
cells in the range B3:E3 and cells in the range B8:E8

have
zeros then those rows should be deleted.

With Range("A1:E9")
.AutoFilter
.AutoFilter 2,0
.AutoFilter 3,0
.AutoFilter 4,0
.AutoFilter 5,0
If .Columns(1).SpecialCells(xlVisible).Count1 Then
.Offset(1).Resize(.Rows.Count-1).SpecialCells

(xlVisible).Delete _
Shift:=xlUp
End If
.AutoFilter
End With

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

.



All times are GMT +1. The time now is 03:10 PM.

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