Private Sub CommandButton3_Click()
Dim i As Long
Dim col1 As Byte
If ComboBox7.Value Like "AUTRE*" Then
If Trim(TBComment) = "" Then
MsgBox "Veuillez, SVP, décrire l'incident dans le champ ""Autre"""
TBComment.SetFocus
Exit Sub
End If
Else
TBComment = ""
End If
'..........................Enlève la protection de la Feuil1................................
Sheets("Feuil1").Unprotect Password:="yoyo77"
'............................................................................................
'On Error Resume Next
With Sheets("Feuil1")
NV = .Range("A65500").End(xlUp).Row + 1
If Trim(TextBox1.Text) <> "" Then Range("a" & NV).Value = CDate(TextBox1.Value)
.Range("B" & NV).Value = ComboBox4.Value
.Range("D" & NV).Value = ComboBox5.Value
.Range("E" & NV).Value = ComboBox6.Value
.Range("F" & NV).Value = ComboBox7.Value
.Range("I" & NV).Value = ComboBox8.Value
.Range("G" & NV).Value = TBComment.Value
If Trim(TextBox2.Text) <> "" Then Range("K" & NV).Value = CDate(TextBox2.Value)
.Range("J" & NV).Value = ComboBox10.Value
.Range("M" & NV).Value = ComboBox9.Value
.Range("C" & NV).Value = ComboBox11.Value
.Range("L" & NV).Value = TextBox6.Value
.Range("H" & NV).Value = TextBox7.Value
End With
'..........................Remet la protection de la Feuil1................................
Sheets("Feuil1").Protect Password:="yoyo77", DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Feuil1").EnableSelection = xlUnlockedCells
'............................................................................................
Unload Me
col1 = Me.ComboBox7.ListIndex + 2
With Sheets("Feuil3")
For i = 2 To .Range("A65500").End(xlUp).Row
If ComboBox7.Value <> "" And .Cells(i, 1).Value = ComboBox5.Value Then .Cells(i, col1).Value = IIf(.Cells(i, col1).Value = "", 1, .Cells(i, col1).Value + 1)
If ComboBox9.Value <> "" And .Cells(i, 1).Value = ComboBox5.Value Then .Cells(i, col1).Value = IIf(.Cells(i, col1).Value = "", 1, .Cells(i, col1).Value + 1)
Next i
End With
End Sub