Bonsoir BIGBB74, le forum
Question maintes fois abordée
En colonne A, certaines cellules contiennent des espaces indésirables et ne sont donc pas vides.
Option Explicit
Sub test()
Dim dico As Object, i As Long, e
Set dico = CreateObject("Scripting.Dictionary")
dico.CompareMode = 1
Application.ScreenUpdating = False
With Sheets(1).Range("a1").CurrentRegion
For i = 2 To .Rows.Count
If .Cells(i, 1).Value <> "" Then
If Not dico.exists(.Cells(i, 1).Value) Then
Set dico(.Cells(i, 1).Value) = .Rows(1)
End If
Set dico(.Cells(i, 1).Value) = _
Union(dico(.Cells(i, 1).Value), .Rows(i))
End If
Next
End With
For Each e In dico.keys
If Not IsSheetExists(e) Then
Sheets.Add(after:=Sheets(Sheets.Count)).Name = e
End If
With Sheets(e).Cells(1)
.CurrentRegion.Clear
dico(e).Copy .Cells
End With
Next
Application.ScreenUpdating = True
End Sub
Function IsSheetExists(ByVal feuille As String) As Boolean
On Error Resume Next
IsSheetExists = Len(Sheets(feuille).Name)
End Function
klin89