Dans mon userform1, bouton nouveauproduit1
j'essaie d'appliquer ce code, cela me detect bien que ma désignation existe mais quand je la change dans ma textbox1
j'ai toujours le même message........
Merci pour vos lumières
design = WorksheetFunction.Match(CStr(TextBox1.Value), .Range("A2:C" & .Range("A" & .Rows.Count).End(xlUp).Row), 0)
If design > 0 Then ' Alors
MsgBox "La désignation " & TextBox1 & " existe déjà." & Chr(13) & "Vous ne pouvez que la modifier.", 16
Exit Sub 'Fin
Else 'Puis
lgmod = WorksheetFunction.Match(CInt(TextBox3.Value), .Range("C2:C" & .Range("A" & .Rows.Count).End(xlUp).Row), 0)
If lgmod > 0 Then ' Alors
MsgBox "Le Modèle " & TextBox3 & " existe déjà." & Chr(13) & "Vous ne pouvez que la modifier.", 16
Exit Sub 'Fin
Else 'Puis
Lgref = WorksheetFunction.Match(CLng(TextBox5.Value), .Range("E2:E" & .Range("A" & .Rows.Count).End(xlUp).Row), 0)
If Lgref > 0 Then
MsgBox "La référence " & TextBox5 & " existe déjà." & Chr(13) & "Vous ne pouvez que la modifier.", 16
Exit Sub 'Fin
End If
End If
End If
On Error GoTo 0
If MsgBox("confirmez-vous l'ajout des données?", vbYesNo, "confirmation") = vbYes Then
derligne = .Range("A" & .Rows.Count).End(xlUp).Row + 1
For i = 1 To 7
.Cells(derligne, i) = Controls("TextBox" & i).Value
Next i
End If
End With