Cara, quase não arrumo tempo para mexer nisso hoje também... Vê se ajuda:
Option Explicit
Public Sub RemoverDuplicados()
Dim wb As Workbook
Dim wsIndex As Worksheet
Dim wsFound As Worksheet
Dim StartTime As Double
Dim EndTime As Double
Dim Key1 As String
Dim Key2 As String
Dim Col1 As Integer
Dim Col2 As Integer
Dim Col3 As Integer
Dim LinTop As Long
Dim UltLindex As Long
Dim UltLfound As Long
Dim Counter As Long
Dim i As Long
Dim j As Long
Dim k As Long
Dim l As Long
StartTime = Timer
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Col1 = 1 'Número da primeira coluna comparadora
Col2 = 2 'Número da segunda coluna comparadora
Col3 = 3 'Número da terceira coluna comparadora
LinTop = 2 'Número da primeira linha sem contar o cabeçalho
Counter = 0 'Início da contagem
Set wb = ThisWorkbook
For i = 1 To wb.Worksheets.Count
Set wsIndex = wb.Worksheets(i)
UltLindex = wsIndex.Cells(Rows.Count, 1).End(xlUp).Row
For j = LinTop To UltLindex
Key1 = wsIndex.Cells(j, Col1).Value & wsIndex.Cells(j, Col2).Value & wsIndex.Cells(j, Col3).Value
wsIndex.Cells(j, Col1).Value = "#@#Index#@#" & wsIndex.Cells(j, Col1).Value
wsIndex.Cells(j, Col1).Calculate
For k = i To wb.Worksheets.Count
Set wsFound = wb.Worksheets(k)
UltLfound = wsFound.Cells(Rows.Count, 1).End(xlUp).Row
For l = UltLfound To LinTop Step -1
Key2 = wsFound.Cells(l, Col1).Value & wsFound.Cells(l, Col2).Value & wsFound.Cells(l, Col3).Value
If Key1 = Key2 Then
wsFound.Cells(l, 1).EntireRow.Delete
Counter = Counter + 1
End If
Next l
Next k
wsIndex.Cells(j, Col1).Value = Replace(wsIndex.Cells(j, Col1).Value, "#@#Index#@#", "")
wsIndex.Cells(j, Col1).Calculate
Next j
Next i
Set wsIndex = Nothing
Set wsFound = Nothing
Set wb = Nothing
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
EndTime = Timer
MsgBox "Processo concluído com sucesso!" & vbNewLine & _
"Foram localizados " & Counter & " registros em multiplicidade." & vbNewLine & _
"Tempo do processamento: " & EndTime - StartTime & " segundos."
End Sub
Qualquer coisa da o grito.
Abraço
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 22/02/2016 10:11 am