
Option Explicit
Sub Trova_Doppione()
Dim Ur As Long, doppione As Long, ir As Long, tot As Long
Dim Rng As Range, cella As Range
On Error Resume Next
Ur = Range("A65000").End(xlUp).Row
Range("A:A").Interior.ColorIndex = xlNone
tot = 0
For ir = 1 To Ur
doppione = Cells(ir, 1).Value
Set Rng = Range(Cells(ir + 1, 1), Cells(Ur, 1))
Set cella = Rng.Find(doppione, LookIn:=xlValues, lookat:=xlWhole)
If Not cella Is Nothing Then
cella.Interior.ColorIndex = 3
tot = tot + 1
End If
Next ir
If tot = 0 Then
MsgBox "Nessun doppione trovato!"
Else
MsgBox "Trovati " & tot & " doppioni"
End If
End Sub
|
Option Explicit
Sub Trova_Doppione()
Dim Ur As Long
Dim Cell As Range
Dim i As Long
Dim j As Long
Ur = Range("A" & Rows.Count).End(xlUp).Row
Range("A1:A" & Ur).Interior.ColorIndex = xlNone
For i = 1 To Ur - 1
Set Cell = Cells(i, 1)
For j = i + 1 To Ur
If Cell = Cells(j, 1) Then Cells(j, 1).Interior.ColorIndex = 3
Next j
Next i
End Sub |
Option Explicit
Sub Trova_Doppione()
Dim Ur As Long, doppione As Variant, ir As Long, tot As Long
Dim Rng As Range, cella As Range
Ur = Range("A65000").End(xlUp).Row
Range("A:A").Interior.ColorIndex = xlNone
tot = 0
For ir = 1 To Ur
If ir = Ur Then Exit For
doppione = Cells(ir, 1).Value
Set Rng = Range(Cells(ir + 1, 1), Cells(Ur, 1))
Set cella = Rng.Find(doppione, LookIn:=xlValues, lookat:=xlWhole)
If Not cella Is Nothing Then
cella.Interior.ColorIndex = 3
tot = tot + 1
End If
Next ir
If tot = 0 Then
MsgBox "Nessun doppione trovato!"
Else
MsgBox "Trovati " & tot & " doppioni"
End If
End Sub |
Option Explicit
Sub Trova_Doppione()
Dim Ur As Long
Dim Cell As Range
Dim i As Long
Dim j As Long
Dim x As Integer
Ur = Range("A" & Rows.Count).End(xlUp).Row
Range("A1:A" & Ur).Interior.ColorIndex = xlNone
For i = 1 To Ur - 1
Set Cell = Cells(i, 1)
x = Application.CountIf(Range("A1:A" & Ur), Cell)
If x > 1 Then
For j = i + 1 To Ur
If Cell = Cells(j, 1) Then Cells(j, 1).Interior.ColorIndex = 3
Next j
End If
Next i
End Sub |
Sub Trova_Doppione()
Dim Ur As Long
Dim cell As Range
Dim Rng As Range
Dim i As Long
Dim Er As Long
Ur = Range("A" & Rows.Count).End(xlUp).Row
Range("A1:A" & Ur).Interior.ColorIndex = xlNone
For i = 1 To Ur - 1
Set Rng = Range(Cells(i + 1, 1), Cells(Ur, 1))
On Error Resume Next
WorksheetFunction.Index(Rng, WorksheetFunction.Match(Cells(i, 1), Rng, 0)).Interior.ColorIndex = 3
If Err.Number = 0 Then Er = Er + 1
On Error GoTo 0
Next i
MsgBox "Sono stati trovati N. " & Er & " doppioni"
End Sub |
WorksheetFunction.Match 'meglio il metodo find a questo punto... On Error Resume Next 'me lo avevi contestato.... 'Ma soprattutto On Error GoTo 0 'Non se pò vedè.... ^_^ |
Sub colora_duplicate() 'trovata su internet
Cells(4, 11) = Now
Dim t As Single
t = Timer
Dim q&, x&, i&, a
Dim ash As Worksheet
Set ash = ActiveSheet
q = Range("A" & Rows.Count).End(3).Row - 3
a = Range("A2").Resize(q)
Application.ScreenUpdating = False
With Sheets.Add
.Cells(1).Resize(q) = a
.Cells(2) = 1: .Cells(2).Resize(q).DataSeries
.Cells(1).Resize(q, 2).Sort .Cells(1), 1, Header:=xlNo
a = .Cells(1).Resize(q + 1)
For i = 1 To q
If a(i, 1) <> a(i + 1, 1) Then
If i > x + 1 Then _
.Cells(x + 2, 1).Resize(i - x - 1).Font.ColorIndex = 3
x = i
End If
Next i
.Cells(1).Resize(q, 2).Sort .Cells(2), 1, Header:=xlNo
.Cells(1).Resize(q).Copy ash.Range("A2")
Application.DisplayAlerts = False
.Delete
Application.DisplayAlerts = True
End With
Application.ScreenUpdating = True
'MsgBox "controllato in " & Format(Timer - t, "0.00 secs"), 0, "Avviso"
Cells(4, 12) = Now
End Sub
|
