Total automatique exel 2019 Nombre en lettre.

Résolu
DJAMALOS Messages postés 332 Date d'inscription vendredi 9 mai 2008 Statut Membre Dernière intervention 23 mars 2024 - 3 janv. 2024 à 18:50
DJAMALOS Messages postés 332 Date d'inscription vendredi 9 mai 2008 Statut Membre Dernière intervention 23 mars 2024 - 3 janv. 2024 à 20:56

Bonjour,

Cherche fonction nombre en lettre VBA excel 2019 

total automatique  : exemple : 1 889 912, 68 DA

Un Million Huit Cent Quatre Vingt Neuf Mille Neuf Cent Douze et 68 Centimes.

Au debut de chaque lettre en Majuscule.

Merci.


Windows / Edge 120.0.0.0

A voir également:

2 réponses

Mrneige0 Messages postés 2 Date d'inscription mercredi 3 janvier 2024 Statut Membre Dernière intervention 3 janvier 2024 1
3 janv. 2024 à 19:12

Essaie ça 

Function NombreEnLettres(ByVal Montant As Double) As String
    Dim Unités As Variant, Dizaines As Variant, Centaines As Variant
    Dim T As String, R As String
    Dim Num As String, DecimalPart As String
    
    Unités = Array("", "Un", "Deux", "Trois", "Quatre", "Cinq", "Six", "Sept", "Huit", "Neuf")
    Dizaines = Array("", "Dix", "Vingt", "Trente", "Quarante", "Cinquante", "Soixante", "Soixante", "Quatre-Vingt", "Quatre-Vingt")
    Centaines = Array("", "Cent", "Deux Cent", "Trois Cent", "Quatre Cent", "Cinq Cent", "Six Cent", "Sept Cent", "Huit Cent", "Neuf Cent")
    
    Num = Format(Abs(Montant), "###0.00")
    DecimalPart = Right(Num, 2)
    
    If Len(Num) > 6 Then
        R = Unités(Int(Left(Num, Len(Num) - 6))) & " Million "
        Num = Right(Num, 6)
    End If
    
    If Len(Num) > 3 Then
        R = R & Centaines(Int(Left(Num, Len(Num) - 3))) & " "
        Num = Right(Num, 3)
    End If
    
    If Len(Num) > 2 Then
        T = Dizaines(Int(Left(Num, 1)))
        Num = Right(Num, 2)
        
        If T = "Dix" Then
            T = T & " " & Unités(Int(Num))
        ElseIf T = "Vingt" And Left(Num, 1) = "1" Then
            T = T & "-" & "Et-" & Unités(Right(Num, 1))
        ElseIf T = "Quatre-Vingt" And Left(Num, 1) = "1" Then
            T = T & "-" & "Et-" & Unités(Right(Num, 1))
        ElseIf T <> "" Then
            T = T & "-"
        End If
        
        R = R & T
    End If
    
    If Len(R) > 0 And Right(R, 1) <> "-" Then R = R & " "
    
    If Len(Num) > 0 Then
        R = R & Unités(Int(Num))
    End If
    
    If DecimalPart <> "00" Then
        R = R & " et " & DecimalPart & " Centimes"
    End If
    
    NombreEnLettres = StrConv(Left(R, 1), vbUpperCase) & Mid(R, 2)
End Function
 

insére-la dans un module VBA d'Excel. Ensuite, dans une cellule Excel, tu peux utiliser la formule =NombreEnLettres(A1)

1
DJAMALOS Messages postés 332 Date d'inscription vendredi 9 mai 2008 Statut Membre Dernière intervention 23 mars 2024 3
3 janv. 2024 à 20:56

Merci bcp.

0