~M*E*H*D*I~
2014/05/19, 23:29
http://exceliran.com/up/up/9cd93dae42181948d0ed32e8ca10f413.png (http://www.exceliran.com)
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A:A"
Dim LastRow As Long
Dim i As Long
On Error GoTo ws_exit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Me.Columns(1).Sort key1:=Me.Range("A1"), _
order1:=xlAscending, _
Header:=False
LastRow = Me.Cells(Me.Rows.Count, .Column).End(xlUp).Row
For i = LastRow To 1 Step -1
If Me.Cells(i, .Column).Value = Me.Cells(i - 1, .Column).Value Then
Me.Rows(i).Delete
End If
Next i
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A:A"
Dim LastRow As Long
Dim i As Long
On Error GoTo ws_exit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Me.Columns(1).Sort key1:=Me.Range("A1"), _
order1:=xlAscending, _
Header:=False
LastRow = Me.Cells(Me.Rows.Count, .Column).End(xlUp).Row
For i = LastRow To 1 Step -1
If Me.Cells(i, .Column).Value = Me.Cells(i - 1, .Column).Value Then
Me.Rows(i).Delete
End If
Next i
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub