XL 2019 chiffre lettre

bauerjackob

XLDnaute Junior
Bonsoir
j'ai reçu d'un bon ami la simple traduction en lettre que j'apprécie beaucoup. Mais le petit problème c(est qu'elle est limité à millier pas en million
Pourriez-vous m'aider à le faire en million. voir PJ
 

Pièces jointes

  • Chiffre lettre1.xlsm
    9.3 KB · Affichages: 15

danielco

XLDnaute Accro
Bonjour,
J'ai conservé cette macro complémentaire dont je ne me rappelle plus l'auteur :
VB:
'***********
' Devise=0   aucune
'       =1   Euro €
'       =2   Dollar $
'       =3   franc Pacifique

' Langue=0   Français
'       =1   Belgique
'       =2   Suisse
'***********
' Conversion limitée à 999 999 999 999 999 ou 9 999 999 999 999,99
' si le nombre contient plus de 2 décimales, il est arrondit à 2 décimales


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 = " Euro"
            If byDec > 0 Then strCentimes = strCentimes & " Cents"
        Case 2
            strDev = " Dollar"
            If byDec > 0 Then strCentimes = strCentimes & " Cent"
        Case 3
            strDev = " Franc"
            If byDec > 0 Then strCentimes = strCentimes & " Cent"
    End Select
    If dblEnt > 1 And Devise <> 0 Then strDev = strDev & "s"
    ConvNumberLetter = ConvNumEnt(CDbl(dblEnt), Langue) & strDev & " " & _
        ConvNumDizaine(byDec, Langue) & strCentimes
'    If ConvNumEnt(CDbl(dblEnt), Langue) = "un" Then ConvNumberLetter = ConvNumEnt(CDbl(dblEnt), Langue) & _
'      " franc Pacifique" & ConvNumDizaine(byDec, Langue) & strCentimes
End Function

La fonction est : "ConvNumberLetter" et le paramètre à passer est le nombre. Par exemple : =ConvNumberLetter(C1)

Daniel
 

Pièces jointes

  • NbLettre.xlam
    22.2 KB · Affichages: 13

bauerjackob

XLDnaute Junior
Bonjour,
J'ai conservé cette macro complémentaire dont je ne me rappelle plus l'auteur :
VB:
'***********
' Devise=0   aucune
'       =1   Euro €
'       =2   Dollar $
'       =3   franc Pacifique

' Langue=0   Français
'       =1   Belgique
'       =2   Suisse
'***********
' Conversion limitée à 999 999 999 999 999 ou 9 999 999 999 999,99
' si le nombre contient plus de 2 décimales, il est arrondit à 2 décimales


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 = " Euro"
            If byDec > 0 Then strCentimes = strCentimes & " Cents"
        Case 2
            strDev = " Dollar"
            If byDec > 0 Then strCentimes = strCentimes & " Cent"
        Case 3
            strDev = " Franc"
            If byDec > 0 Then strCentimes = strCentimes & " Cent"
    End Select
    If dblEnt > 1 And Devise <> 0 Then strDev = strDev & "s"
    ConvNumberLetter = ConvNumEnt(CDbl(dblEnt), Langue) & strDev & " " & _
        ConvNumDizaine(byDec, Langue) & strCentimes
'    If ConvNumEnt(CDbl(dblEnt), Langue) = "un" Then ConvNumberLetter = ConvNumEnt(CDbl(dblEnt), Langue) & _
'      " franc Pacifique" & ConvNumDizaine(byDec, Langue) & strCentimes
End Function

La fonction est : "ConvNumberLetter" et le paramètre à passer est le nombre. Par exemple : =ConvNumberLetter(C1)

Daniel
trop long et non en vba voir mon fichier
 

p56

XLDnaute Occasionnel
Bonjour à tous,
Sans VBA =>
Capture d’écran 2022-11-01 182004.jpg
 

Pièces jointes

  • Somme_en_Lettres.xlsx
    12.4 KB · Affichages: 15

Discussions similaires

Membres actuellement en ligne

Statistiques des forums

Discussions
312 505
Messages
2 089 071
Membres
104 020
dernier inscrit
Mzghal