1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| Sub PlanForma()
Dim Mini As Integer, Maxi As Integer, AnneePlus, PF, DL_SF&, Nom, SF, i&, j&, L$, TB_L
Mini = -5: Maxi = 5
Do
If AnneePlus Then MsgBox "Merci de mettre un entier compris entre " & Mini & " et " & Maxi
AnneePlus = Application.InputBox("Ajouter un nombre d'année(s) supplémentaire(s)" & vbCr & "+ ou - sur l'année en cours", "ANNÉE SUPPLÉMENTAIRE VOULU", Type:=1)
If AnneePlus = "False" Then Exit Sub
Loop Until AnneePlus = Fix(AnneePlus) And AnneePlus >= Mini And AnneePlus <= Maxi
With Sheets("PLAN FORMATION")
Application.ScreenUpdating = False
.Range("A1").Value = "PLAN DE FORMATION " & Year(Date) + AnneePlus
With .Range("E4:P59")
.Value = ""
PF = .Value
With Sheets("SUIVI FORMATIONS")
DL_SF = .Cells(Rows.Count, 1).End(xlUp).Row
Nom = .Range("A5:B" & DL_SF).Value
SF = .Range("F5:BI" & DL_SF).Value
For j = 2 To UBound(SF, 2) Step 2
For i = 1 To UBound(SF)
If SF(i, j) > "" Then
If Year(SF(i, j)) = Year(Date) + AnneePlus Then
PF(j, Month(SF(i, j))) = IIf(PF(j, Month(SF(i, j))) = "", Nom(i, 1) & " - " & Nom(i, 2), PF(j, Month(SF(i, j))) & vbCr & Nom(i, 1) & " - " & Nom(i, 2))
If Not L Like "*" & j + 3 & "*" Then L = L & " " & j + 3 'Récupération des lignes incriminées pour la mise en forme/couleur dans PLAN FORMATION
End If
End If
Next
Next
End With
.Value = PF
.Rows.AutoFit
End With
With .Range("A4:D59") 'Réinitialisation de la mise en forme/couleur de A4 à D59
.Interior.ColorIndex = xlNone
.Font.Bold = False
.Font.Color = 1
End With
TB_L = Split(Trim(L), " ")
For i = LBound(TB_L) To UBound(TB_L) 'Mise en forme/couleur de A4 à D59 - PS pas bien les cellules fusionnées, en général on les évite ;) mais bon ici c'est pas très grave ;)
For j = 1 To 4
If .Cells(TB_L(i), j).MergeArea.Count > 1 Then
With .Cells(TB_L(i), j).MergeArea
.Interior.ColorIndex = 6
.Font.Bold = True
If j > 3 Then .Font.ColorIndex = 10
End With
Else
.Cells(TB_L(i), j).Interior.ColorIndex = 6
.Cells(TB_L(i), j).Font.Bold = True
If j > 3 Then .Cells(TB_L(i), j).Font.ColorIndex = 10
End If
Next
Next
Application.ScreenUpdating = True
End With
End Sub |
Partager