Surprise Me!

Excel - Réaliser un convertisseur de chiffre en lettres

2016-02-29 95 Dailymotion

Cette vidéo va vous montrer comment convertir des chiffres en toutes lettres. <br /> <br />Ci-dessous le code de la fonction : <br /> <br />Public Function ChiffreLettre(Valeur) <br /> <br /> 'Déclaration des variables <br /> Dim MesValeurs As Variant, GrosMontant As Variant <br /> Dim Espace As String <br /> <br /> 'Affectation des variables dans un tableau de type Array <br /> MesValeurs = Array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept", _ <br /> "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix sept", _ <br /> "dix huit", "dix neuf", "vingt", "vingt et un", "vingt deux", "vingt trois", "vingt quatre", _ <br /> "vingt cinq", "vingt six", "vingt sept", "vingt huit", "vingt neuf", "trente", "trente et un", _ <br /> "trente deux", "trente trois", "trente quatre", "trente cinq", "trente six", "trente sept", _ <br /> "trente huit", "trente neuf", "quarante", "quarante et un", "quarante deux", "quarante trois", _ <br /> "quarante quatre", "quarante cinq", "quarante six", "quarante sept", "quarante huit", _ <br /> "quarante neuf", "cinquante", "cinquante et un", "cinquante deux", "cinquante trois", _ <br /> "cinquante quatre", "cinquante cinq", "cinquante six", "cinquante sept", "cinquante huit", _ <br /> "cinquante neuf", "soixante", "soixante et un", "soixante deux", "soixante trois", _ <br /> "soixante quatre", "soixante cinq", "soixante six", "soixante sept", "soixante huit", _ <br /> "soixante neuf", "soixante dix", "soixante et onze", "soixante douze", "soixante treize", _ <br /> "soixante quatorze", "soixante quinze", "soixante seize", "soixante dix sept", _ <br /> "soixante dix huit", "soixante dix neuf", "quatre-vingts", "quatre-vingt un", _ <br /> "quatre-vingt deux", "quatre-vingt trois", "quatre-vingt quatre", "quatre-vingt cinq", _ <br /> "quatre-vingt six", "quatre-vingt sept", "quatre-vingt huit", "quatre-vingt neuf", _ <br /> "quatre-vingt dix", "quatre-vingt onze", "quatre-vingt douze", "quatre-vingt treize", _ <br /> "quatre-vingt quatorze", "quatre-vingt quinze", "quatre-vingt seize", "quatre-vingt dix sept", _ <br /> "quatre-vingt dix huit", "quatre-vingt dix neuf") <br /> GrosMontant = Array("", "billions", "milliards", "millions", "mille", "euros", "billion", _ <br /> "milliard", "million", "mille", "euro") <br /> Espace = Space(1) <br /> chaine = "00000000000000" 'Limite de ma valeur à 14 chiffre => Billion <br /> centime = Valeur * 100 - (Int(Valeur) * 100) <br /> Valeur = Str(Int(Valeur)): lg = Len(Valeur) - 1: Valeur = Right(Valeur, lg): lg = Len(Valeur) <br /> If lg "" And C & d = "" Then mydz = "Euros" & Espace: GoTo fin <br /> If T "" And C = "" And d = "un" Then mydz = "un euros" & Espace: GoTo fin <br /> If T "" And t2 = "" And C & d = "" Then mydz = "d'Euros" & Espace: GoTo fin <br /> If T & C & d = "" Then myct = "": mydz = "": GoTo fin <br /> End If <br /> If C & d = "" Then GoTo fin <br /> If d = "" And C "" And C "un" Then mydz = C & Espace & "cents " & GrosMontant(k) & Espace: GoTo fin <br /> If d = "" And C = "un" Then mydz = "cent " & GrosMontant(k) & Espace: GoTo fin <br /> If d = "un" And C = "" Then myct = IIf(k = 4, GrosMontant(k) & Espace, "un " & GrosMontant(k + 5) & Espace): GoTo fin <br /> If d "" And C = "un" Then mydz = "cent" & Espace <br /> If d "" And C "" And C "un" Then mydz = C & Espace & "cent" + Espace <br /> myct = d & Espace & GrosMontant(k) & Espace <br />fin: <br /> t2 = mydz & myct <br /> T = T & mydz & myct <br /> mydz = "": myct = "" <br /> gp = gp + 3 <br /> Next <br /> d = MesValeurs(centime) <br /> If T "" Then myct = IIf(centime = 1, " centime", " centimes") <br /> If T = "" Then myct = IIf(centime = 1, " centime d'Euro", " centimes d'Euro") <br /> If centime = 0 Then d = "": myct = "" <br /> ChiffreLettre = T & d & myct <br />End Function

Buy Now on CodeCanyon