Erreur fichier VBA pour convertir nombre en lettre > 2

21nblettre.zip (22.06 Ko)

Bonjour à tous,

J'ai un problème sur mon fichier VBA pour convertir les nombres en lettre quand ils sont inférieurs à 2... Pouvez-vous m'aider à trouver l'erreur, je suis vraiment novice en VBA...

merci d'avance

Si vous voulez quand je tape la formule, si le nombre demandé est compris entre 0 et 1.99 la cellule reste vide, si c'est 2 ou plus ca convertit bien en lettres.

Bonjour,

Essayez ceci:

Public Function ConvNumberLetter(Nombre As Double, Optional Devise As Byte = 0, Optional Langue As Byte = 0) As String
    Dim dblEnt As Variant, byDec As Byte
    Dim bNegatif As Boolean
    Dim strDev As String, strCentimes As String

    If Nombre < 0 Then
        bNegatif = True
        Nombre = Abs(Nombre)
    End If
    dblEnt = Int(Nombre)
    byDec = CInt((Nombre - dblEnt) * 100)
    If byDec = 0 Then
        If dblEnt > 999999999999999# Then
            ConvNumberLetter = "#TropGrand"
            Exit Function
        End If
    Else
        If dblEnt > 9999999999999.99 Then
            ConvNumberLetter = "#TropGrand"
            Exit Function
        End If
    End If
    Select Case Devise
        Case 0
            If byDec > 0 Then strDev = " virgule"
        Case 1
            strDev = " Euros"
            If byDec > 0 Then strCentimes = strCentimes & " Centimes"
        Case 2
            strDev = " Dollars"
            If byDec > 0 Then strCentimes = strCentimes & " Cent"
        Case 3
            strDev = " FCFA"
            If byDec > 0 Then strCentimes = strCentimes & " Centimes"
        Case 4
            strDev = " GNF"
            If byDec > 0 Then strCentimes = strCentimes & " Centimes"
        Case 5
            strDev = " KES"
            If byDec > 0 Then strCentimes = strCentimes & " Cents"
        Case 6
            strDev = " Ariarys"
            If byDec > 0 Then strCentimes = strCentimes & " Centimes"
        Case 7
            strDev = " Dirhams"
            If byDec > 0 Then strCentimes = strCentimes & " Centimes"
    End Select
    If dblEnt = 0 And byDec <> 0 Then
        ConvNumberLetter = Langue & strDev & " " & ConvNumDizaine(byDec, Langue) & strCentimes
    Else
        If dblEnt > 0 Then
            ConvNumberLetter = ConvNumEnt(CDbl(dblEnt), Langue) & strDev & " " & ConvNumDizaine(byDec, Langue) & strCentimes
        End If
    End If
End Function

Cdlt

Bonjour Arturo83,

Merci beaucoup pour votre aide, ca marche nickel !

Seb

Rechercher des sujets similaires à "erreur fichier vba convertir nombre lettre"