Private Sub Actualiser_Planning() 'valider
Application.ScreenUpdating = False
Dim col%, lig%, Salarie%, CP%, Nb%
Dim Ctrl As Object
If Me.TextBox1.Value = "" Then MsgBox ("Vous n'avez pas saisie la date"): Me.TextBox1.SetFocus: Exit Sub
Nb = 0
With Sheets("PLANNING")
For lig = 5 To 159 Step 14
If Month(.Cells(lig, 2)) = Month(Me.TextBox2) Then
For col = 2 To 32
If DateSerial(Year(.Cells(lig, 2)), Month(.Cells(lig, 2)), col) = CDate(Me.TextBox2.Value) Then
For Salarie = lig + 1 To lig + 11
If .Cells(Salarie, 1).Value = Me.ComboBox1.Value Then
'If VALIDATION.Caption = "MODIFIER" Then Me.TextBox5.Value = Me.TextBox5.Value - 1
For CP = col + 1 To col + CInt(Me.TextBox5.Value)
Nb = Nb + 1
If Me.OptionButton1 = True Then
.Cells(Salarie, CP) = "CP"
Else
.Cells(Salarie, CP) = "CSS"
End If
If CP = .Cells(lig, Columns.Count).End(xlToLeft).Column Then
If Nb >= CInt(Me.TextBox5.Value) Then Exit Sub
Salarie = Salarie + 14
CP = 2
If Me.OptionButton1 = True Then
.Cells(Salarie, CP) = "CP"
Else
.Cells(Salarie, CP) = "CSS"
End If
Nb = Nb + 1
End If
If Nb >= CInt(Me.TextBox5.Value) Then Exit Sub
Next CP
Exit Sub
End If
Next Salarie
End If
Next col
End If
Next lig
End With
Sheets("PLANNING").Activate
Unload Me
End Sub