
Sub Nascondere_righe_doppie()
Dim cell As Range, CellsToHide As Range, derLi As Long
Application.ScreenUpdating = False
derLi = Cells(Rows.Count, 1).End(xlUp).Row
For i = derLi To 2 Step -1
If Not IsError(Application.Match(Cells(i, 1).Value, _
Range("A2:A" & i - 1), 0)) Then
If CellsToHide Is Nothing Then
Set CellsToHide = Cells(i, 1)
Else: Set CellsToHide = Union(CellsToHide, Cells(i, 1))
End If
End If
Next i
If Not CellsToHide Is Nothing Then _
CellsToHide.EntireRow.Hidden = True
End Sub |
Sub elimina_righe()
Dim derLi As Long, i As Long
Application.ScreenUpdating = False
derLi = Cells(Rows.Count, 1).End(xlUp).Row
'applico il filtro sulla colonna A
Range("A2:A" & derLi).AdvancedFilter Action:=xlFilterInPlace, Unique:=True
'ciclo dall'ultima alla prima cella: se la riga è nascosta la elimino (perché doppia)
For i = derLi To 1 Step -1
If Rows(i).Hidden = True Then Rows(i).Delete
Next
Application.ScreenUpdating = True
End Sub
|
