View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1480_] Rick Rothstein \(MVP - VB\)[_1480_] is offline
external usenet poster
 
Posts: 1
Default Deleting a row that has a zero in column A

Sorry, I grabbed a previous response to a similar question (only it wanted
to hide, not delete, the rows) and did a terrible job of modifying it for
your question. Here is the code I should have posted...

Sub DeleteRowIfZeroInA()
Dim X As Long
Dim R As Range
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
For X = LastRow To 1 Step -1
If .Cells(X, "A").Value = 0 And .Cells(X, "A").Value < "" Then
.Cells(X, "A").EntireRow.Delete xlShiftUp
End If
Next
End With
End Sub

Rick

"Rick Rothstein (MVP - VB)" wrote in
message ...
Give this macro a try...

Sub HideRowIfZeroInA()
Dim R As Range
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
For Each R In .Range("A3:A" & CStr(LastRow))
If R.Value = 0 And R.Value < "" Then R.EntireRow.Hidden = True
Next
End With
End Sub

Note: Change the reference to Sheet1 (keep the quote marks) in the
With statement to the actual sheet name you want to hide the
rows on.

Rick


"Bob" wrote in message
...
I would like to know how I would build a macro that deletes an entire row
that has a zero in column A. For example, my column A has values greater
than 0 until the end of the report and then the values are all be zeros:

16
10
8
7
5
0
0
0

I would like a macro that deletes the entire row that has a zero in
column A.

Thanks.

Bob


--
Bob