Sub test()
Dim addr$, mot$, oldmot$, i&, c As Range, firstAddress$, punion As Range, cel As Range
With Worksheets("Base")
Set plage = .Range("b2:b" & .Cells(Rows.Count, "b").End(xlUp).Row)
oldmot = .Cells(2, 1).Text
.Cells(Rows.Count, 1).End(xlUp).Offset(1) = "xxxx" 'obligé d'ajouter sinon il prend pas la derniere va savoir pourquoi
For i = 2 To .Cells(Rows.Count, "A").End(xlUp).Row
If .Cells(i, "A").Text <> "" Then
mot = .Cells(i, "A").Text
If mot <> oldmot Then
If Not punion Is Nothing Then
If Not punion.Cells(1) Like "*" & oldmot & "*" Then Set punion = Range(Replace(punion.Address, punion.Cells(1).Address & ",", ""))
'nextrow = Sheets("résultat").Cells(Rows.Count, 2).End(xlUp).Offset(3).Row
'Sheets("résultat").Cells(nextrow, 1) = oldmot
'For Each area In punion.Areas
'For Each cel In area.Cells
'nextrow = Sheets("résultat").Cells(Rows.Count, 2).End(xlUp).Offset(1).Row
'Sheets("résultat").Cells(nextrow, 2) = cel.Text
'Next
'Next
Debug.Print oldmot & " : " & punion.Address: oldmot = mot: Set punion = Nothing
End If
End If
Set c = plage.Find(mot, Lookat:=xlPart)
If Not c Is Nothing Then
firstAddress = c.Address
Do
If punion Is Nothing Then Set punion = c Else Set punion = Union(punion, c)
addr = addr & c.Address & " "
Set c = plage.FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End If
Next
.Cells(Rows.Count, 1).End(xlUp) = ""
End With
End Sub