in column A, I would like to check if there are cells with equal values and if I find them I would like one of them to be deleted, but with this macro, I delete both cells
Sub Elina_Tutti_I_Doppioni_2()
Dim LastRow As Long, K As Long, MemoCanc As Variant
Application.ScreenUpdating = False
With ActiveSheet
.Columns("A").Sort .[a1], Header:=xlGuess
LastRow = [COUNTA(A:A)]
For K = LastRow To 2 Step -1
If .Cells(K, 1) = .Cells(K - 1, 1) Or MemoCanc = .Cells(K, 1) Then
MemoCanc = .Cells(K, 1)
.Rows(K).EntireRow.Delete
End If
Next
End With
Application.ScreenUpdating = True
End Sub