View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
peter peter is offline
external usenet poster
 
Posts: 36
Default Help with a loop

I am using the following code to delete all rows that do
not contain a 1 in column C. It works on ALL rows in a
worksheet. I need it to only work within a selection
(A2:H128). I can't seem to get anything to work. Any
suggestions? TIA

Dim RowNdx1 As Long
Dim LastRow1 As Long
Sheets("TEST").Select
LastRow1 = ActiveSheet.Cells(Rows.Count, "C").End
(xlUp).Row
For RowNdx1 = LastRow1 To 2 Step -1
With Cells(RowNdx1, "C")
If .Value < 1 Then
Rows(RowNdx1).Delete
End If
End With
Next RowNdx1