Nombre décimal textbox, décimale à 0

Bonjour à tous !

Lorsque le montant saisi dans mon formulaire (dans une textbox) se retranscrit dans ma cellule, les décimales sont à 0.

Exemple :

Si je saisi 21,09, dans ma cellule il y aura 21,00.

Quelqu'un a une idée du pourquoi ?

Merci

Auriane

Bonjour,

Difficile de diagnostiquer le problème, sans fichier, ni même code.

Mais bon je vais tenter une réponse quand même, peut être au niveau du format de la variable ?

Ou, essayer de renseigner le format au moment du renseignement dans la cellule ?

Cdlt,

Oups pardon, voici l'intégralité de mon code sur ce formulaire

Private Sub UserForm_Initialize()
     montant = Format(montant, "#,00")
End Sub

Private Sub intitule_Change()

    montant = Format(montant, "#,00")

    If intitule = "Salaire" Then
        montant = 1650
        credit = True
    End If
    If intitule = "Assurance habitation" Then
        montant = 12.5
        debit = ture
    End If
    If intitule = "Assurance voiture" Then
        montant = 41
        debit = ture
    End If
    If intitule = "Loyer" Then
        montant = 325
    End If
    If intitule = "Séolis" Then
        montant = 65
        debit = True
    End If
    If intitule = "Internet" Then
        montant = 13
        debit = True
    End If
    If intitule = "Crédit voiture" Then
        montant = 266.3
        debit = True
    End If
    If intitule = "Crédit renouvelable CM" Then
        montant = 28.17
        debit = True
    End If
    If intitule = "Crédit Sofinco" Then
        montant = 28
        debit = True
    End If
    If intitule = "Mutuelle" Then
        montant = 5.23
        debit = True
    End If
    If intitule = "Caution" Then
        montant = 21.09
        debit = True
    End If

End Sub

Private Sub validerFermer_Click()

Dim solde As Integer
Dim derligne As Integer
Dim montantSaisie As Integer

derligne = Range("A6000").End(xlUp).Row

If credit = True Then
    montantSaisie = montant
Else
    montantSaisie = -montant
End If

Range("A" & derligne + 1).NumberFormat = "@"
Range("A" & derligne + 1) = Format(laDate, "dd/mm/yyyy")
Range("A" & derligne + 1).Offset(0, 1).Value = intitule
Range("A" & derligne + 1).Offset(0, 2).Value = montantSaisie

solde = Range("F1").Value + montantSaisie
Range("F1").Value = solde

Range("A2:A6000").Select
ActiveWorkbook.Worksheets("Budget").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Budget").Sort.SortFields.Add Key:=Range("A2:A6000") _
    , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Budget").Sort
    .SetRange Range("A1:C6000")
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
End With

Range("A1").Select

laDate = Date
montant = ""
intitule = ""
credit = False
debit = False

budget.Hide

End Sub

Private Sub validerNouv_Click()

Dim solde As Integer
Dim derligne As Integer
Dim montantSaisie As Integer

derligne = Range("A6000").End(xlUp).Row

If credit = True Then
    montantSaisie = montant
Else
    montantSaisie = -montant
End If

Range("A" & derligne + 1).NumberFormat = "@"
Range("A" & derligne + 1) = Format(laDate, "dd/mm/yyyy")
Range("A" & derligne + 1).Offset(0, 1).Value = intitule
Range("A" & derligne + 1).Offset(0, 2).Value = montantSaisie

solde = Range("F1").Value + montantSaisie
Range("F1").Value = solde

Range("A2:A6000").Select
ActiveWorkbook.Worksheets("Budget").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Budget").Sort.SortFields.Add Key:=Range("A2:A6000") _
    , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Budget").Sort
    .SetRange Range("A1:C6000")
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
End With

Range("A1").Select

laDate = Date
montant = ""
intitule = ""
credit = False
debit = False

End Sub

Private Sub annuler_Click()
    budget.Hide
End Sub

Merci !

bonjour

m'semble ou, je dois confondre avec Word

"# ##0,00"

crdlt,

André

Rechercher des sujets similaires à "nombre decimal textbox decimale"