Una macros para colorear al mismo tiempo los datos repetidos

Necesito q la macros coloree los datos repetitivos y a su vez guarde en un contador cuantos datos repetitivos hay en la columna c

Ejemplo

A B C

Fila 5 126

Fila 15 802

Fila 30 487

Fila 80 487

Fila 120 126

Fila 135 802

Fila 136 12356

Lo puese asi para diferenciarlos pero esto se colorean de color amarillo = 6

Este problema se me presento como en la ultima fila llena de la columna c no tiene datos repetivos termina el bucle con el contarsi=1

Espero me puedan ayudar con esta macro ya q quiero agregarle un msgbox en este caso hay 6 datos repetitivos.. Al final..

Sub COLOREAR_DUPLI()
Application.ScreenUpdating = False
Range("D65000").End(xlUp).Offset(1, 0).Value = "final"
Range("D1").Select
Do While ActiveCell.Value <> "final"
contarsi = Application.WorksheetFunction.CountIf(Columns(4), ActiveCell)
If contarsi > 1 Then
ActiveCell.EntireRow.Interior.ColorIndex = 6
End If
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell. ClearContents

gracias de antemano.. Edinson

1 Respuesta

Respuesta
3

Te anexo una macro, es diferente a tu macro, pero funciona para lo que necesitas.

Sub contarduplicados()
'cuenta duplicados y los pone de amarillo
'Por.Dam
Range("C5:C" & Range("C" & Rows.Count).End(xlUp).Row).Interior.ColorIndex = xlNone
For i = 5 To Range("C" & Rows.Count).End(xlUp).Row
    ant = Cells(i, 3)
    For j = i + 1 To Range("C" & Rows.Count).End(xlUp).Row
        nvo = Cells(j, 3)
        If ant = nvo Then
            If Cells(j, 3).Interior.ColorIndex <> 6 Then
                Cells(j, 3).Interior.ColorIndex = 6
                Cells(i, 3).Interior.ColorIndex = 6
            End If
        End If
    Next
Next
For i = 5 To Range("C" & Rows.Count).End(xlUp).Row
    If Cells(i, 3).Interior.ColorIndex = 6 Then cont = cont + 1
Next
MsgBox "Números Duplicados" & vbNewLine & vbNewLine & cont, vbInformation, "Módulo de Duplicados"
End Sub

Saludos.Dam
Si es lo que necesitas.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas