Sub Coloriage()
Dim objCollabos As Object, Col1 As Range, ChampCible As Range, NbLignes As Long, NbColonnes As Long, i%, j%, wkCollabos As Worksheet, wkProd As Worksheet, Combo1$, Combo2$, Combo3$, Combo4$
Set wkCollabos = ThisWorkbook.Worksheets("BDD Fiches de Formation")
Set objCollabos = wkCollabos.ListObjects("_Collaborateurs")
Set wkProd = ThisWorkbook.Worksheets("MdP Prod")
Set Col1 = objCollabos.ListColumns("Colonne1").DataBodyRange
Set ChampCible = wkProd.Range("PolyProd[[Colonne2]:[a415]]") '$N$14:$PM$79 - si des colonnes sont ajoutées APRÈS la colonne PM, remplacer la dernière valeur entre crochets (ici a415) par le nouveau nom de la dernière colonne
NbLignes = ChampCible.Rows.Count
NbColonnes = ChampCible.Columns.Count
Application.ScreenUpdating = False
usfInfo.Afficher
For i = 1 To NbLignes
usfInfo.Actualiser CInt((i / NbLignes) * 100)
For j = 1 To NbColonnes
Combo1 = wkProd.Cells(5, j + 13) & wkProd.Cells(i + 13, 1)
Combo2 = wkProd.Cells(6, j + 13) & wkProd.Cells(i + 13, 1)
Combo3 = wkProd.Cells(7, j + 13) & wkProd.Cells(i + 13, 1)
Combo4 = wkProd.Cells(8, j + 13) & wkProd.Cells(i + 13, 1)
If ChampCible.Cells(i, j) <> "" And (Application.WorksheetFunction.CountIf(Col1, Combo1) + Application.WorksheetFunction.CountIf(Col1, Combo2) + Application.WorksheetFunction.CountIf(Col1, Combo3) + Application.WorksheetFunction.CountIf(Col1, Combo4)) < Application.WorksheetFunction.CountA(wkProd.Cells(9, j + 13), wkProd.Cells(10, j + 13), wkProd.Cells(11, j + 13), wkProd.Cells(12, j + 13)) Then
With ChampCible(i, j).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 13590431
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else
ChampCible(i, j).Interior.ColorIndex = xlColorIndexNone
End If
Next j
Next i
Application.ScreenUpdating = True
Set wkCollabos = Nothing
Set objCollabos = Nothing
Set wkProd = Nothing
Set Col1 = Nothing
Set ChampCible = Nothing
End Sub