VBA Format numérique lors du transfert

Bonjour à tous,

J'ai un userform, lorsque je saisie mes Textbox, dans celle du temps (Textebox4), quand je saisie 10.50 il me transfert 0, et quand je met 10,50 il me transfert 11.

Voici ma fonction:

Function copy_from_form()
Dim LastRow As Long

LastRow = ActiveWorkbook.Sheets("SaveTemps").Range("A1000000").End(xlUp).Row
LastRow = LastRow + 1

If TBDate = "" Or ComboBox1 = "" Or TextBox4 = "" Then ' Or  TBDate <> Format(Date, "dd/mm/yyyy")
MsgBox ("Des informations sont manquantes ou éronnées !!")
Else

With ActiveWorkbook.Sheets("SaveTemps")
.Range("A" & LastRow).Value = WorksheetFunction.Max(Feuil19.Range("A:A")) + 1
.Range("B" & LastRow).Value = Format(TBDate.Value, "dd/mm/yyyy")
.Range("C" & LastRow).Value = ComboBox1.Value
.Range("D" & LastRow).Value = ComboBox2.Value
.Range("E" & LastRow).Value = TextBox5.Value
.Range("F" & LastRow).Value = TextBox6.Value
.Range("G" & LastRow).Value = TextBox2.Value
.Range("H" & LastRow).Value = TextBox3.Value
.Range("I" & LastRow).Value = Format(TextBox4.Value, "0,00")
.Range("J" & LastRow).Value = Format(Month(TBDate) & Year(TBDate), "#####")
End With
End If
End Function

Y a-t-il un moyen pour que la saisie soit transférer correctement en numérique ?

De plus, lors de la saisie des écritures de le userform, comme peut-on obliger un format d'écriture?

Merci à tous !

RQ

Bonjour

.Range("I" & LastRow).Value = val(TextBox4.Value)

contrôle le format de la colonne I

Tu parles de temps ... c'est 10h30 (10:30) ou 10h et 50 centième?

A+ François

Bonjour François,

Comme c'est pour de la facturation, je préfère le laisser en numérique : 10,50

A+ Rocco

Hello,

avec le VBA il faut le séparateur "." et pas ",".

essayez :

.Range("I" & LastRow).Value = Format(TextBox4.Value, "0.00")

Bonjour,

    .Range("I" & LastRow).Value = Format(CDec(TextBox4.Value), "0.00")
Rechercher des sujets similaires à "vba format numerique lors transfert"