Sub MAJ_XP()
'---se lance par les touches Ctrl+M---
Dim UT As Range, tablo, d As Object, i&, nlig&, ncol%, j%
With Sheets("CALENDRIERS UT")
Set UT = .Rows("8:9").Find(Left([A1], 3), , xlValues) 'recherche en lignes 8-9 à adapter
If UT Is Nothing Then Exit Sub
tablo = .Range(UT, .Cells(.Rows.Count, UT.Column).End(xlUp)) 'matrice, plus rapide
If Not IsArray(tablo) Then Exit Sub 'sécurité
End With
If MsgBox("Les XP vont être entrés, voulez-vous continuer ?", 4) = 7 Then Exit Sub
'---liste des jours de garde---
Set d = CreateObject("Scripting.Dictionary")
For i = 2 To UBound(tablo)
If tablo(i, 1) <> "" Then If Weekday(tablo(i, 1), 2) > 5 Or Application.CountIf([Feries], tablo(i, 1)) Then d(tablo(i, 1)) = ""
Next i
'---traitement du tableau de destination---
With [A1].CurrentRegion
nlig = .Rows.Count
If nlig = 1 Then nlig = nlig + 1 'au moins 2 éléments
ncol = .Columns.Count - 2 'colonne Commentaires déduite
If ncol < 1 Then ncol = 1
tablo = .Columns(2).Resize(nlig, ncol) 'matrice, plus rapide
For i = 3 To nlig
If d.exists(.Cells(i, 1).Value) Then
For j = 1 To ncol
tablo(i, j) = "XP"
Next j
End If
Next i
Application.ScreenUpdating = False
With .Columns(2).Resize(, ncol)
.Replace "XP", "", xlWhole 'RAZ
.Value = tablo 'restitution
End With
End With
End Sub