Dim p As MSForms.Page, c As Control, i As Integer, x As Long, T() As Variant
For Each p In reporter_un_incident_part2.MultiPage_KE.Pages
For Each c In reporter_un_incident_part2.MultiPage_KE.Pages(p.Name).Controls
If TypeName(c) = "CheckBox" Then
If c.Value = True Then
i = i + 1
ReDim Preserve T(1 To i)
T(i) = c.Caption
End If
End If
Next c
Next p
If i = 0 Then
Call MsgBox("Vous n'avez coché aucun system defects", vbExclamation, Application.Name)
ElseIf i > 4 Then Call MsgBox("Vous avez coché plus de 4 system defects", vbExclamation, Application.Name)
Else:
Do While UBound(T) < 4
i = i + 1
ReDim Preserve T(1 To i)
T(i) = "Non applicable"
Loop
x = Columns(22).Find("", Cells(Rows.Count, 22), xlValues, , 1, 1, 0).Row
Cells(x, 22).Resize(1, Columns.Count - 21).Find("", Cells(x, Columns.Count), xlValues, , 2, 1, 0).Resize(1, UBound(T)).Value = T
With Sheets("report")
.Cells(.Cells(Rows.Count, "U").End(xlUp).Row + 1, "U") = reporter_un_incident_part2.ComboBox_immediate_cause.Value
End With
End If