PDA

View Full Version : Solved: Deleting rows with odd conditions



rudy1
08-02-2007, 12:52 PM
Ok so I know I'm making this much harder than this is so here's my dilemna.

I want to delete rows that have any sort of info in Column C.
and
I also want to delete rows where Column B equals zero.

I want to get it into VBA so I can assign buttons but can't figure out where to start.

Thanks in advance.

Bob Phillips
08-02-2007, 01:22 PM
Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim iLastRow As Long

With ActiveSheet

Application.ScreenUpdating = False

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow To 1 Step -1
If .Cells(i, "C").Value <> "" Or _
.Cells(i, "B").Value = 0 Then
.Rows(i).Delete
End If
Next i

Application.ScreenUpdating = True

End With

End Sub

rudy1
08-02-2007, 01:30 PM
Thank you so much. It worked beautifully.

n8Mills
08-02-2007, 03:19 PM
Hi, Rudy,

Make sure to mark this as "Solved" (look in the Thread Tools)

thx,

Nate