Private Sub CommandButton1_Click()
Dim tablo, ub&, d As Object, i&, a, j%, resu$(), classe, n&
tablo = [A1].CurrentRegion.Resize(, 3) 'matrice, plus rapide
ub = UBound(tablo)
'---liste des classes---
Set d = CreateObject("Scripting.Dictionary")
For i = 2 To ub
If tablo(i, 1) <> "" Then d(tablo(i, 3)) = ""
Next i
If d.Count = 0 Then Exit Sub 'tableau vide, sécurité
'---création des fichiers txt---
a = d.keys
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With Workbooks.Add(xlWBATWorksheet) 'nouveau document
For j = 0 To UBound(a)
ReDim resu(1 To ub, 1 To 1)
classe = a(j)
n = 0
.Sheets(1).Cells.Clear 'RAZ
For i = 2 To ub
If tablo(i, 3) = classe Then
n = n + 1
resu(n, 1) = tablo(i, 1) & " " & tablo(i, 2)
End If
Next i
.Sheets(1).Cells(1).Resize(n) = resu 'restitution
.SaveAs ThisWorkbook.Path & "\" & classe, xlText
Next j
.Close False
End With
End Sub