VBA/Excel : Compter le nombre de doublons d'une plage

Bonjour,

j'ai vu le code déjà présent sur le site pour supprimer les doublons d'une colonne

Sub doublon()
Dim derlign As Long, i As Long, j As Long
Application.ScreenUpdating = False
derlign = [a65536].End(xlUp).Row
i = 2
Do While i <= derlign
j = 0
Do While Left(Cells(i, 1), 8) = Left(Cells(i + j, 1), 8)
j = j + 1
Loop
 If j <= 2 Then Rows(i + j - 1 & ":" & i).Delete shift:=xlShiftUp: derlign = [a65536].End(xlUp).Row Else i = i + j
Loop
End Sub

Je cherche le nombre de doublons et pas la suppression au fur et à mesure en remontant les lignes....

Est-il possible d'utiliser un countif en vba??? s'il me renvoit > 1 alors doublons...

=COUNTIF(B1:AB50;mavariable)

Help je galère j'ai pas mal cherché mais je cherche un code propre

merci

Bonjour ketamacanna,

Me dit quelque chose ce code

Il faudrait voir comment se présente ton fichier pour adapter une solution. En attendant, tu peux essayer avec un truc comme ça :

Sub nbDoublons()
Dim i As Integer, j As Byte, plage As Range, prec As String
    Application.ScreenUpdating = False
    Set plage = Range("B1:AB50")
    prec = ""
    For i = 1 To 50
        For j = 2 To 28
            With Application.WorksheetFunction
                If .CountIf(plage, Cells(i, j)) > 1 And Cells(i, j) <> prec Then
                    MsgBox "Il y a " & .CountIf(plage, Cells(i, j)) & " fois la valeur " & Cells(i, j)
                End If
            End With
            prec = Cells(i, j)
        Next j
    Next i
End Sub

Ça ne devrait pas faire tout ce que tu souhaites donc à toi d'adapter.

Rechercher des sujets similaires à "vba compter nombre doublons plage"