Delete Rows
Hi,
Sample data in Activesheet
--Row-------A-----------------B-----------------------------
1 Number <== Label
2 1 <==First number
3 2
4 3
.. .
.. .
.. .
29995 29994
29996 29995
29997 1000 <== out of order
29998 29997
29999 29998
30000 29999
30001 30000
------------------------------------------------------------
Try the following code:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Option Explicit
Sub TEST()
Dim R As Long
Dim N As Double
R = Cells(Rows.Count, 1).End(xlUp).Row
If R < 3 Then GoTo e:
N = Evaluate("MIN(IF(A2:A" & (R - 1) & "A3:A" & _
R & ",ROW(A3:A" & R & "),""""))")
If N = 0 Then GoTo e:
Range("A" & R & ":A" & N).EntireRow.Delete
e:
End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
Regards,
Soo Cheon Jheong
_ _
^вп^
--
|