0
Thanks

A few words of thanks would be greatly appreciated.

Excel - Conditional deletion of rows



Issue


I have a spreadsheet where column A is a project name then columns B, C and D are financial data for the specific project. What I would like to do is delete the entire row for the project only if columns B, C and D contain zero's. I can set up a filter and filter out zero's for 1 specific column, but in many of the rows only 1 or 2 of the 3 columns are zero's so that does not work.

Solution


Try with this macro (assuming that the first row contained the titles).

Public Sub DELETE_Rows_CellZero_Col_B_C_D()  
Dim x As Long  
Dim y As Long  
x = Range("C65536").End(xlUp).Row  

For y = x To 2 Step -1  

    If Cells(y, 2).Value = 0 And Cells(y, 3).Value = 0 And Cells(y, 4).Value = 0 Then  
      
        Rows(y).Delete  
      
    End If  

Next y  
End Sub
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « Excel - Conditional deletion of rows », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

0 Comments