macro

C

C3

HI!

How to make a macro who will find some value (etc. 0) in a specific column
(etc. column B), and erase entire row.

Thanks.
 
F

Frank Kabel

Hi
try the following macro
Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
with Cells(RowNdx, "B")
if .value = 0 then
Rows(RowNdx).Delete
End If
end with
Next RowNdx
Application.ScreenUpdating = True
End Sub
 
D

Don Guillett

something like this to check column A
Sub delzeros()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Cells(i, 1) = 0 Then Rows(i).Delete
Next
End Sub
 
B

Bob Phillips

If there is just one or no occurrence, use the Find method. Add FindNext if
multiple occurrences.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
A

Art

Keep in mind that depending upon what values are allowed in your spreadsheet, you might need to watch out for empty cells and cells with the value of FALSE. I believe that these will also evaluate to 0. If necessary you can use the IsEmpty function to test for empty cells. Also, you can use the Str function to convert your cell to a string. This should help to identify cells that are FALSE

Art
 
Top