Créer une liste de mots répétés dans une colonne

cecemeursault

XLDnaute Nouveau
Bonjour,
Je voudrais créer, dans excel, une liste de mots qui sont répétés dans une colonne. Je vous donne un exemple :
voici la colonne où les mots seront répétés :

REMARQUE

Fatigant
ennuyeux
long
Fatigant

Je voudrais qu'excel détecte que le mot "fatigant" est répétés plusieurs fois et me dresse à coté une liste de ces mots.
Merci par avance.
 

BOISGONTIER

XLDnaute Barbatruc
Repose en paix
Re : Créer une liste de mots répétés dans une colonne

Bonjour,

Liste des doublons

Code:
Set MonDico = CreateObject("Scripting.Dictionary")
Set MonDico2 = CreateObject("Scripting.Dictionary")
For Each c In Range([a2], [a65000].End(xlUp))
  If MonDico.exists(c.Value) Then MonDico2.Item(c.Value) = ""
  MonDico.Item(c.Value) = ""
Next c
If MonDico2.Count > 0 Then [E2].Resize(MonDico2.Count, 1) = Application.Transpose(MonDico2.keys)

JB
 

Pièces jointes

  • Doublons.xls
    35.5 KB · Affichages: 28
  • Doublons.xls
    35.5 KB · Affichages: 31
Dernière édition:

klin89

XLDnaute Accro
Re : Créer une liste de mots répétés dans une colonne

Bonsoir le forum,

J'ai cru comprendre que tu étais sur Mac.
VB:
Option Explicit

Sub Doublons_Mac()
Dim a, b(), i As Long, e, n As Long, flag As Boolean
    Application.ScreenUpdating = False
    With Sheets(1)
        a = .Range("a2", .Range("a" & Rows.Count).End(xlUp)).Value
        ReDim b(1 To UBound(a, 1), 1 To 1)
        For Each e In a
            If n = 0 Then
                n = n + 1
                b(n, 1) = e
            Else
                For i = 1 To n
                    If e = b(i, 1) Then
                        flag = True
                        Exit For
                    End If
                Next
                If Not flag Then
                    n = n + 1
                    b(n, 1) = e
                End If
                flag = False
            End If
        Next
        With .Range("d1")
            .CurrentRegion.Clear
            .Resize(n, 1).Value = b
            With .CurrentRegion
                .Font.Name = "calibri"
                .VerticalAlignment = xlCenter
                .HorizontalAlignment = xlCenter
                .Borders(xlInsideVertical).Weight = xlThin
                .BorderAround Weight:=xlThin
            End With
        End With
    End With
    Application.ScreenUpdating = True
End Sub
klin89
 

BOISGONTIER

XLDnaute Barbatruc
Repose en paix
Re : Créer une liste de mots répétés dans une colonne

Bonjour,

Pour MAC

Code:
Sub ListeDoublonsMAC()
   a = Range([a2], [a65000].End(xlUp))
   Dim d1(): ReDim d1(1 To UBound(a))
   Dim d2(): ReDim d2(1 To UBound(a))
   pd1 = 0: pd2 = 0
   For Each c In a
    If Not IsError(Application.Match(c, d1, 0)) Then pd2 = pd2 + 1: d2(pd2) = c
    pd1 = pd1 + 1: d1(pd1) = c
  Next c
  [E2].Resize(pd2) = Application.Transpose(d2)
End Sub

+ rapide

Code:
Sub ListeDoublonsMAC2()
   a = Range([a2], [a65000].End(xlUp))
   Dim d1(): ReDim d1(1 To UBound(a))
   Dim d2(): ReDim d2(1 To UBound(a))
   pd1 = 0: pd2 = 0
   For Each c In a
      existe = False
      For i = 1 To pd1
        If c = d1(i) Then existe = True
      Next i
      If existe Then pd2 = pd2 + 1: d2(pd2) = c
      pd1 = pd1 + 1: d1(pd1) = c
  Next c
  [E2].Resize(pd2) = Application.Transpose(d2)
End Sub

++ rapide

Code:
Sub DoublonsCollectionMAC()
   Dim Collec1 As New Collection
   Dim Collec2 As New Collection
   a = Range([a2], [a65000].End(xlUp))
   For Each c In a
     On Error Resume Next
     Collec1.Add Item:=c, Key:=c
     If Err > 0 Then Collec2.Add Item:=c
   Next c
   On Error GoTo 0
   Dim b(): ReDim b(1 To Collec2.Count)
   For i = 1 To Collec2.Count
     b(i) = Collec2(i)
   Next i
   [c2].Resize(Collec2.Count) = Application.Transpose(b)
End Sub

JB
 

Pièces jointes

  • LSDMac.xls
    46.5 KB · Affichages: 25
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
314 223
Messages
2 107 498
Membres
109 844
dernier inscrit
odyn