Views

Histats

Vitrine

VBA Excel - Deletando linhas duplicadas - Delete duplicate rows


Public Sub DelDupliRows (rng As Range)' Author:                  Date:                   Contact:' André Bernardes 29/01/2009 12:18 bernardess@gmail.com' Esta SUB deletará registros (linhas) duplicadas, será baseada no Range passado' como parâmetro. Quando esta SUB achar mais duma ocorrência no mesmo Range,' todas as ocorrências seguintes serão deletadas.
Dim r As LongDim n As LongDim v As Variant
On Error GoTo EndMacro
Let Application.ScreenUpdating = FalseLet Application.Calculation = xlCalculationManualLet Application.StatusBar = "Linha sendo processada: " & _ Format(rng.Row, "#,##0")
Let n = 0
For r = rng.Rows.Count To 2 Step -1If r Mod 500 = 0 ThenLet Application.StatusBar = "Processing Row: " & Format(r, "#,##0")End If
Let v = rng.Cells(r, 1).Value
If v = vbNullString ThenIf Application.WorksheetFunction.CountIf(rng.Columns(1), vbNullString) > 1 Thenrng.Rows(r).EntireRow.DeleteLet n = n + 1End IfElseIf Application.WorksheetFunction.CountIf(rng.Columns(1), v) > 1 Thenrng.Rows(r).EntireRow.DeleteLet n = n + 1End IfEnd IfNext r
EndMacro:Let Application.StatusBar = FalseLet Application.ScreenUpdating = TrueLet Application.Calculation = xlCalculationAutomatic
MsgBox CStr(n) & "Linha(s) Duplicada(s) Deleta(s) "End Sub

Deixe os seus comentários! Envie este artigo, divulgue este link na sua rede social...


Tags: VBA, Excel, Column, Coluna, Delete, Linha, Plan, Planilhas, Report, Row,  rows,worksheet, lines, duplicate, duplicado, dados, paste, cut


✔ VBA Brazil®

✔ VBA Brazil®
brazilsalesforceeffectiveness@gmail.com
Related Posts Plugin for WordPress, Blogger...
diHITT - Notícias