Private Sub CommandButton1_Click()
Dim Valeur As String, i As Integer, cpt As Integer
'Pour P09
With Sheets("P09")
'les Combo
cpt = 0
For i = 2 To 3
If ComboBox5.Value = "P09" Then
If .Cells(3, i + cpt).Value = "" Then
.Cells(3, i + cpt).Value = Controls("ComboBox" & i).Value
Else
.Cells(65536, i + cpt).End(xlUp).Offset(1, 0).Value = Controls("ComboBox" & i).Value
End If
End If
cpt = 4
Next i
If ComboBox5.Value = "P09" Then
If .Range("i3") = "" Then
.Range("i3").Value = ComboBox6.Value
Else
.Range("i65536").End(xlUp).Offset(1, 0).Value = ComboBox6.Value
End If
End If
'les Textbox
cpt = 0
For i = 2 To 5
If ComboBox5.Value = "P09" Then
If .Cells(3, i + 1).Value = "" Then
.Cells(3, i + 1).Value = Controls("TextBox" & i).Value
Else
.Cells(65536, i + 1).End(xlUp).Offset(1, 0).Value = Controls("TextBox" & i).Value
End If
End If
Next i
For i = 6 To 7
If ComboBox5.Value = "P09" Then
If .Cells(3, i - 5 + cpt).Value = "" Then
.Cells(3, i - 5 + cpt).Value = Controls("TextBox" & i).Value
Else
.Cells(65536, i - 5 + cpt).End(xlUp).Offset(1, 0).Value = Controls("TextBox" & i).Value
End If
End If
cpt = 6
Next i
End With
'Pour P10
'...
End Sub
Private Sub CommandButton1_Click()
Dim Valeur As String, i As Integer, cpt As Integer
With Sheets(ComboBox5.Text)
'les Combo
cpt = 0
For i = 2 To 3
If .Cells(3, i + cpt).Value = "" Then
.Cells(3, i + cpt).Value = Controls("ComboBox" & i).Value
Else
.Cells(65536, i + cpt).End(xlUp).Offset(1, 0).Value = Controls("ComboBox" & i).Value
End If
cpt = 4
Next i
If .Range("i3") = "" Then
.Range("i3").Value = ComboBox6.Value
Else
.Range("i65536").End(xlUp).Offset(1, 0).Value = ComboBox6.Value
End If
'les Textbox
cpt = 0
For i = 2 To 5
If .Cells(3, i + 1).Value = "" Then
.Cells(3, i + 1).Value = Controls("TextBox" & i).Value
Else
.Cells(65536, i + 1).End(xlUp).Offset(1, 0).Value = Controls("TextBox" & i).Value
End If
Next i
For i = 6 To 7
If .Cells(3, i - 5 + cpt).Value = "" Then
.Cells(3, i - 5 + cpt).Value = Controls("TextBox" & i).Value
Else
.Cells(65536, i - 5 + cpt).End(xlUp).Offset(1, 0).Value = Controls("TextBox" & i).Value
End If
cpt = 6
Next i
End With
End Sub