Il faut donc ajouter 10 qui correspond à la colonne K du tableau qui commence à la deuxième colonne.
ET ajouter une quatrième colonne au filtre
Option Explicit
Public critere%
Sub dispatcher()
Dim Tbl As Variant, data As Variant, i%
Dim dico1 As Object, cle1 As Variant, result1 As Variant
Dim wb As Excel.Workbook
Dim MonRepertoire, Repertoire As FileDialog, racine As String
Dim colonne$
racine = Split(ThisWorkbook.Name, ".")(0)
Set Repertoire = Application.FileDialog(msoFileDialogFolderPicker)
Application.FileDialog(msoFileDialogFolderPicker).Title = "Choix du répertoire de stockage des fichiers générés"
Repertoire.Show
If Repertoire.SelectedItems.Count = 0 Then Exit Sub
MonRepertoire = Repertoire.SelectedItems(1)
data = Cells(Rows.Count, 2).End(xlUp).CurrentRegion
Set dico1 = CreateObject("Scripting.Dictionary")
For i = LBound(data) + 1 To UBound(data) ' hors en-tête
dico1(data(i, 10)) = "" ' colonne K
dico1(data(i, 11)) = "" ' colonne L (écart de 1 car le tableau commence colonne 2)
dico1(data(i, 12)) = "" ' colonne M
dico1(data(i, 13)) = "" ' colonne N
Next
Application.ScreenUpdating = False
For Each cle1 In dico1.Keys
If cle1 <> "" Then
result1 = filtreArray(data, 10, 11, 12, 13, cle1)
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & "Model.xlsx")
wb.Sheets(1).Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Resize(UBound(result1, 1), UBound(result1, 2)) = result1
wb.SaveAs (MonRepertoire & "\" & racine & "_" & cle1 & ".xlsx")
wb.Close
Set wb = Nothing
End If
Next
Application.ScreenUpdating = True
MsgBox "Terminé, fichiers sauvegardés sous """ & MonRepertoire & "\" & """ !"
End Sub
et
Function filtreArray(Tbl, col1, col2, col3, col4, param)
Dim i%, j%, k%, n%
For i = 1 To UBound(Tbl)
If Tbl(i, col1) = param Then n = n + 1
If Tbl(i, col2) = param Then n = n + 1
If Tbl(i, col3) = param Then n = n + 1
If Tbl(i, col4) = param Then n = n + 1
Next i
Dim temp: ReDim temp(1 To n, 1 To UBound(Tbl, 2))
j = 0
For i = 1 To UBound(Tbl)
If Tbl(i, col1) = param Or Tbl(i, col2) = param Or Tbl(i, col3) = param Or Tbl(i, col4) = param Then
j = j + 1
For k = 1 To UBound(Tbl, 2)
temp(j, k) = Tbl(i, k)
Next k
End If
Next i
filtreArray = temp
End Function