Thread: Delete Rows
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Delete Rows

Dim rng as Range, cell as Range
set rng = Cells(rows.count,1).End(xlup)
set cell = range("A2")
do while cell.value < ""
if cell.Value < cell.offset(-1,0).Value then
range(cells(cell,rng).EntireRow.Delete
exit do
end if
set cell = cell.offset(1,0)
Loop

--
Regards,
Tom Ogilvy

"jerry chapman" wrote in message
...
I have an Excel file which is sorted ascending by column one. I would like
to write a macro to verify that, and if I find a row which is out of order

I
would like to delete that row and all subsequent rows. How could I do

that?