macro for deleting rows based on specific value

  • Thread starter Thread starter hailnorm
  • Start date Start date
H

hailnorm

Is there a way to have a macro delete the entire row of data if a cel
value in that specific row is 0 (or some specific value)?

I receive weekly reports which contain a ton of data. All I need ar
rows in which the total is not zero. Right now, I'm sorting by th
amount column (column AG) & then deleting all rows where the total i
equal to zero which is a few thousand rows. The columns spans from #
to #AK
 
Manually, you could apply data|filter|autofilter.

Then show the 0 rows and delete those visible rows.

then remove the filter if you want or just show the remaining data:
data|filter|showall
 
Hi
try the following macro
try
Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long

LastRow = ActiveSheet.Cells(Rows.Count, "AG").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "AG").Value = 0 Then
Rows(RowNdx).Delete
End If
Next RowNdx
End Sub
 
I have a very similar question. I wrote a query that returned thousand
of rows, many of which are redundant rows that I need to filter out.
Because of the multiple inner joins it would just be easier to get ri
of my duplicate rows. But what I need to do is compare cell A2 with A
if they are the same delete the current row and repeat the check unti
A2 and A3 are different. Then I need to drop to the next row an
repeat until the cell is empty. Can someone help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top