ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to delete that row if same cell in preceding row is identical (https://www.excelbanter.com/excel-programming/409940-how-delete-row-if-same-cell-preceding-row-identical.html)

Ronmarco

How to delete that row if same cell in preceding row is identical
 
I have data that duplicates a cell in the previous row and I want to delete
the second row each time that happens.

Office_Novice

How to delete that row if same cell in preceding row is identical
 

Sub NewOne()
Do Until ActiveCell.Value = ""
If ActiveCell.Value = ActiveCell.Offset(-1, 0).Value Then
ActiveCell.EntireRow.Delete Shift:=xlUp
ElseIf ActiveCell.Value < ActiveCell.Offset(-1, 0).Value Then
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub

"Ronmarco" wrote:

I have data that duplicates a cell in the previous row and I want to delete
the second row each time that happens.


Jeff Johnson[_2_]

How to delete that row if same cell in preceding row is identical
 
"Office_Novice" wrote in message
...

ActiveCell.EntireRow.Delete Shift:=xlUp


For reference, when you delete an entire row, there's only one way to
shift....




All times are GMT +1. The time now is 11:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com