Cellules à blnc

AHMED TOUATI -  
f894009 Messages postés 17277 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,
Aprés validation de mes données ( des dates et montants) je recoi toujours un débogage alors que je voudrai que si les cellules ne porte rien doivent etre validés à un blanc et non pas un zéro (0) et voila mon code
Dim ctrl As Control
Dim r As Integer
Dim t As Integer
Dim derligne As Integer

Dim texte As String, nombre As Double
texte = Range("e92")

If ZLISTE_CLIENT = "" Then
MsgBox ("Vous devez obligatoirement saisir le nom du client"), vbCritical + vbOKOnly
MsgBox ("Recalculez les sommes avant de validé"), vbCritical + vbOKOnly
MsgBox ("Pour la 3° fois vérifier bien les opérations avant de valider"), vbCritical + vbOKOnly

End If

If MsgBox("NOM DU CLIENT EST INDISPENSABLE", vbCritical + vbOKCancel, "NOM DU CLIENT OBLIGATOIR !") = vbOK Then

With Worksheets("feuil1")
derligne = .Range("A65536").End(xlUp).Row + 1
derligne = .Range("C65536").End(xlUp).Row + 1

For Each ctrl In ENREGIST_FACTURES.Controls
r = Val(ctrl.Tag)
If r > 0 Then Feuil1.Cells(derligne, r) = ctrl
Next

If ZLISTE_CLIENT = "" Then
TXTITEM.SetFocus
End If



If TXTDREGL = "" Then
TXTDREGL = 0
End If

If TXTD1_LIGNE1 = "" Then
TXTD1_LIGNE1 = 0
End If


If TXTD2_LIGNE1 = "" Then
TXTD2_LIGNE1 = 0
End If

If TXTD1_LIGNE2 = "" Then
TXTD1_LIGNE2 = 0
End If


If TXTD2_LIGNE2 = "" Then
TXTD2_LIGNE2 = 0
End If

Feuil1.Cells(derligne, 1) = Val(TXTITEM)
Feuil1.Cells(derligne, 2) = CDate(TXTDFACTURE.Value)
Feuil1.Cells(derligne, 3) = Val(ZLISTE1)
Feuil1.Cells(derligne, 5) = Val(TXTMTHT)
Feuil1.Cells(derligne, 6) = Val(TXTMTREMISE)
Feuil1.Cells(derligne, 7) = Val(TXTMTTVA)
Feuil1.Cells(derligne, 8) = Val(TXTMTTTC)
Feuil1.Cells(derligne, 9) = Val(TXTMTREGLE)
Feuil1.Cells(derligne, 10) = Val(TXTSOLDE)
Feuil1.Cells(derligne, 11) = CDate(TXTDREGL)
Feuil1.Cells(derligne, 13) = Val(ZLISTE2)

Feuil1.Cells(derligne, 16) = Val(TXTN_LIGNE1)
Feuil1.Cells(derligne, 17) = TXTDESI
Feuil1.Cells(derligne, 18) = CDate(TXTD1_LIGNE1)
Feuil1.Cells(derligne, 19) = CDate(TXTD2_LIGNE1)
Feuil1.Cells(derligne, 20) = Val(TXTNJ_LIGNE1)
Feuil1.Cells(derligne, 21) = Val(TXTPU_LIGNE1)
Feuil1.Cells(derligne, 22) = Val(TXTMTHT_LIGNE1)

Feuil1.Cells(derligne, 23) = Val(TXTN_LIGNE2)
Feuil1.Cells(derligne, 24) = TXTDESI_LIGNE2
Feuil1.Cells(derligne, 25) = CDate(TXTD1_LIGNE2)
Feuil1.Cells(derligne, 26) = CDate(TXTD2_LIGNE2)
Feuil1.Cells(derligne, 27) = Val(TXTNJ_LIGNE2)
Feuil1.Cells(derligne, 28) = Val(TXTPU_LIGNE2)
Feuil1.Cells(derligne, 29) = Val(TXTMTHT_LIGNE2)

If NOUVEAU = True Then TXTITEM = WorksheetFunction.Max(Feuil1.Range("A2:a2000")) + 1
If NOUVEAU = True Then ZLISTE1 = WorksheetFunction.Max(Feuil1.Range("C2:c2000")) + 1


Worksheets("Feuil1").Range("A" & Rows.Count).End(xlUp).EntireRow.Copy Worksheets("SAVBD").Range("A" & Rows.Count).End(xlUp)(2)


For Each w In Application.Workbooks
w.Save
Next w


Unload ENREGIST_FACTURES
Load ENREGIST_FACTURES
ENREGIST_FACTURES.Show

TXTITEM.SetFocus

End Sub

veuillez m'orienter svp sur la bonne voie et mes remerciements anticipées


1 réponse

f894009 Messages postés 17277 Date d'inscription   Statut Membre Dernière intervention   1 714
 
Bonjour,

Faites comme ceci:
au lieu de faire ces tests:
If TXTDREGL = "" Then
TXTDREGL = 0
End If
et autres

Remplacez pour ce test:
Feuil1.Cells(derligne, 11) = CDate(TXTDREGL)        'ici
par:
If TXTDREGL <> "" Then Feuil1.Cells(derligne, 11) = CDate(TXTDREGL)        
et ainsi de suite pour les autres
0