Re : Userform multi TextBox
Bonjour,
Remplace ton code par celui-ci (et avec contrôle des doublons)
Private Sub Button_OK_Click()
Dim nom As String
Dim i As Integer, j As Integer, k As Integer
Dim lig(100) As Integer
Dim derligne As Integer
Dim ctrl As Control
Sheets("Feuil1").Activate
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSForms.TextBox Then
'Stop
If ctrl.Value <> "" Then
'Stop
i = i + 1
lig(i) = ctrl.Value
End If
End If
Next
For k = 1 To i
For j = k + 1 To i
If lig(k) = lig(j) Then MsgBox ("Deux fois la valeur " & lig(k)): Exit Sub
Next j
Next k
For Each ctrl In Controls
'If CTRL = ComboBox1 Then GoTo label98
If TypeOf ctrl Is MSForms.TextBox Then
'Stop
[A11].Activate
nom = ctrl.Name
If ctrl.Value = "" Then GoTo suite
Chiffre = ctrl.Value
Do While (ActiveCell.Value <> Chiffre)
rang = rang + 1
ActiveCell.Offset(1, 0).Activate
If rang >= 100 Then
Exit Sub
End If
Loop
' Stop
derligne = Sheets("Feuil2").Range("A65536").End(xlUp).Row + 1
cible = ActiveCell.Row
Range(Cells(cible, 2), Cells(cible, 3)).Copy Destination:=IIf(Sheets("Feuil2").Range("A1") = "", _
Sheets("Feuil2").Range("A1"), Sheets("Feuil2").Range("A" & derligne))
' Unload UserForm1
' Sheets("Feuil2").Select
End If
suite:
Next
End Sub
a+