Delete Rows - include top row

T

TiscaliNews

Using xl2000. In a range of approx 12000 rows, I am deleting rows that match
17 different criteria. Is there an easy way to include the first row?

The main code is a variation on one of Chip Pearson's posts and runs from
the bottom of the range and works upwards using:


Range([a1], [a65536].End(xlUp)).Select

ColNum = Selection(1).Column

For RowNdx = Selection( _
Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1

'Times before 07:40
If Cells(RowNdx, ColNum).Offset(0, 1).Value < 0.319444 Then
Cells(RowNdx, ColNum).EntireRow.Delete
End If

Next RowNdx

i.e., for the above code, if B1 contains, say, 06:30, the above code does
all the rest, but not the first row. Should I just include a "control row"
at the top or is there a better way?

Martin
 
B

Bob Phillips

For RowNdx = Cells(Rows.Count,"A").End(xlUp).Row To 1 Step -1

'Times before 07:40
If Cells(RowNdx, "A").Offset(0, 1).Value < 0.319444 Then
Cells(RowNdx, "A").EntireRow.Delete
End If

Next RowNdx


--

HTH

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

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

Top