'les quatres boutons d'en bas
Private Sub Ajout_Click()
Dim Ok As Boolean, DevNumber&, r As Range, critere
critere = nom <> "" And prenom <> "" And telephone <> "" And mail <> "" And adresse <> ""
If Not critere Then MsgBox "Veuillez saisir tous les champs SVP!!": Exit Sub
'sheets("Sauvegarde").Unprotect ("5158")
Ok = IsDate(DateConsultation.Value)
If Ok Then
Set r = Range("Tsauvegarde").ListObject.ListRows.Add.Range
MsgBox r.Address
DevNumber = Application.Max(Range("tsauvegarde[N° Devis]")) + 1
r.Value = Array(nom, CDate(DateConsultation.Value), prenom, DevNumber, telephone, mail, adresse, _
designation1, iff(IsNumeric(montant1), CDbl(montant1), ""), _
designation2, IIf(IsNumeric(montant2), CDbl(montant2), ""), _
designation3, IIf(IsNumeric(montant3), CDbl(montant3), ""))
With Sheets("devis")
.Activate
.Range("j16") = CDate(DateConsultation.Value)
.[k7] = nom
.[L10] = prenom
.[H3] = DevNumber
.[j13] = adresse
.[j16] = CDate(DateConsultation.Value)
.[A21:A23] = Application.Transpose(Array(designation1, designation2, designation3))
.[M21:M23] = Application.Transpose(Array(montant1, montant2, montant3))
End With
'sheets("sauvegarde").Protect Password:="5158"
If Clientexistant.ListIndex = -1 Then
Set r = Range("tclient").ListObject.ListRows.Add.Range
r.Value = Array(nom, prenom, adresse, telephone, mail)
MsgBox "leclient n'existait pas dans la base de donnée " & vbCrLf & "il a été ajouté "
End If
Unload Me
End If
End Sub