Re,
Bien je ne suis pas prêt à faire du VBA!
J'ai en réalité plusieurs case dans mon useform, donc plusieurs recherche exactement du même type. J'ai modifié le code ainsi mais cela ne fonctionne pas. Je pensais que la boucle pouvait tourner ainsi mais lorsque je lance la macro il y a un problème avec For ... Exit For.
Merci d'avance!
Private Sub ajout_appareil_Click()
With Worksheets("test stock")
dLig = Worksheets("test stock").Range("A" & Rows.Count).End(xlUp).Row
For lig = 4 To dLig
If Cells(lig, 3) = Me.voie1 Then
If Cells(lig, 1) = "" Then
.Cells(lig, 1) = Me.sn_appareil
Worksheets("test stock").Cells(lig, 2) = 1
End If
End If
If Me.voie2 <> "" Then
If Cells(lig, 3) = Me.voie2 Then
If Cells(lig, 1) = "" Then
.Cells(lig, 1) = Me.sn_appareil
Worksheets("test stock").Cells(lig, 2) = 2
End If
End If
' La ligne est trouvée on sort de la boucle
Exit For
Next lig
End With
End Sub