Auto row deletion

  • Thread starter Thread starter rogeraw
  • Start date Start date
R

rogeraw

undefined :mad: I open a csv file into excel and it is sorted into
columns. two of the columns have values in them. If both of the
columns, for each row, have 0.00 as the value I want to delete that
row, there are usually a lot of these rows and I don't want to have to
manually go down a list
of 100+ rows and delete the rows where there are two zero values. How
can I automate this ?
 
The quick-n-dirty answer - no error checking/etc but should get you started.
Change Cells(row,1) to Range("A"&row) if prefer.
Either way, presumed data being checked are in columns A and B so correct as
needed.

Sub mad()
'manipulate a copy of the data
Sheets("Sheet1").Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = "Print"
'
finalrow = Range("A65536").End(xlUp).Row
'
For Row = 2 To finalrow
If Cells(Row, 1).Value = 0 And _
Cells(Row, 2).Value = 0 Then
Cells(Row, 1).EntireRow.Delete
End If
Next
End Sub
 
To Jef G.,

Thanks for reply but your solution does not work and last time I
programmed was in 1-2-3 in the late 80's so I cannot modify.

The zero values are in columns C & D so if on any row the
value in cols C and D are 0.00 I want the row deleting.

Please revisit the macro, thanks.

Roger
 
Back
Top