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 Need to find two consecutive identical cells (in a column).

sub RemoveNonDups()
Dim i as Long, lastrow as Long
lastrow = cells(rows.count,1).End(xlup).row
for i = lastrow to 2 step -1
if cells(i,1).value < cells(i-1).value then
rows(i).Delete
end if
Next
if cells(i,1).value < cells(i+1).value then
rows(1).Delete
End if
End Sub

--
Regards,
Tom Ogilvy


"How did I get here?" <How did I get wrote
in message ...
My machine names are in the first column in a spreadsheet. I need to find

or
flag in some way, those instances in which a machine name in one row
is followed by the same name appearing again in the next row's first

column.


It would be fine (but not necessary) to reveal this by deleting all other
rows
that do not repeat in this way.

Thanks,
john c