LE NEWSMAGAZINE Nº1 DES NOUVELLES TECHNOLOGIES
167 utilisateurs connectés

Excel 2007 : Ecrire un chiffre en lettre [résolu]

Quenlutincile le 30 juin 2009 à 17h25
Bonjour,

J'ai Excel 2007 sous Windows XP.
Je souhaite une formule qui permet d'écrire un chiffre en lettre.
exemple : 2009 => deux mille neuf
118 => cent dix-huit

J'ai essayé et n'ai rien trouvé sur Excel.
J'ai trouvé le sujet suivant sur le forum mais il parle d'excel 2003 et j'ai du mal avec les liens de début d'année 2007. http://forum.telecharger.01net.com/microhebdo/logiciels/bureautique/comment_c(...)

Quelqu'un peut-il m'aider ?
Merci d'avance.
A+
-->Message édité par Quenlutincile le 24/07/2009 11:09:34<--
Starfire le 30 juin 2009 à 18h25
:hello: Bonjour,

Essaie cet outil : http://www.excel-downloads.com/forum/attachments/forum-excel/48625d1161955928(...)

Il faut être inscrit sur ce forum pour le télécharger.
-->Message édité par Starfire le 30/06/2009 18:28:37<--
-------
Windows Vista Intégral 64 Bits - 6 Go RAM - 1To SATA - Intel Core 2 Quad 2.7 gHz
 
willyplaisir le 30 juin 2009 à 18h41
bonjour,

tu sauvegardes cette fonction dans ton fichier perso.
ensuite tu ecris cette fonction dans la cellule de ton choix

Function Chiffrelettre(s)
Dim a As Variant, gros As Variant
a = Array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept", _
"huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix sept", _
"dix huit", "dix neuf", "vingt", "vingt et un", "vingt deux", "vingt trois", "vingt quatre", _
"vingt cinq", "vingt six", "vingt sept", "vingt huit", "vingt neuf", "trente", "trente et un", _
"trente deux", "trente trois", "trente quatre", "trente cinq", "trente six", "trente sept", _
"trente huit", "trente neuf", "quarante", "quarante et un", "quarante deux", "quarante trois", _
"quarante quatre", "quarante cinq", "quarante six", "quarante sept", "quarante huit", _
"quarante neuf", "cinquante", "cinquante et un", "cinquante deux", "cinquante trois", _
"cinquante quatre", "cinquante cinq", "cinquante six", "cinquante sept", "cinquante huit", _
"cinquante neuf", "soixante", "soixante et un", "soixante deux", "soixante trois", _
"soixante quatre", "soixante cinq", "soixante six", "soixante sept", "soixante huit", _
"soixante neuf", "soixante dix", "soixante et onze", "soixante douze", "soixante treize", _
"soixante quatorze", "soixante quinze", "soixante seize", "soixante dix sept", _
"soixante dix huit", "soixante dix neuf", "quatre-vingts", "quatre-vingt un", _
"quatre-vingt deux", "quatre-vingt trois", "quatre-vingt quatre", "quatre-vingt cinq", _
"quatre-vingt six", "quatre-vingt sept", "quatre-vingt huit", "quatre-vingt neuf", _
"quatre-vingt dix", "quatre-vingt onze", "quatre-vingt douze", "quatre-vingt treize", _
"quatre-vingt quatorze", "quatre-vingt quinze", "quatre-vingt seize", "quatre-vingt dix sept", _
"quatre-vingt dix huit", "quatre-vingt dix neuf")
gros = Array("", "billions", "milliards", "millions", "mille", "Euros", "billion", _
"milliard", "million", "mille", "Euro")
sp = Space(1)
chaine = "00000000000000"
centime = s * 100 - (Int(s) * 100)
s = Str(Int(s)): lg = Len(s) - 1: s = Right(s, lg): lg = Len(s)
If lg < 15 Then chaine = Mid(chaine, 1, (15 - lg)) Else chaine = ""
s = chaine + s
'billions au centaines
gp = 1
For k = 1 To 5
x = Mid(s, gp, 1): C = a(Val(x))
x = Mid(s, gp + 1, 2): D = a(Val(x))
If k = 5 Then
If t2 <> "" And C & D = "" Then mydz = "Euros" & sp: GoTo fin
If t <> "" And C = "" And D = "un" Then mydz = "un Euros" & sp: GoTo fin
If t <> "" And t2 = "" And C & D = "" Then mydz = "d'Euros" & sp: GoTo fin
If t & C & D = "" Then myct = "": mydz = "": GoTo fin
End If
If C & D = "" Then GoTo fin
If D = "" And C <> "" And C <> "un" Then mydz = C & sp & "cents " & gros(k) & sp: GoTo fin
If D = "" And C = "un" Then mydz = "cent " & gros(k) & sp: GoTo fin
If D = "un" And C = "" Then myct = IIf(k = 4, gros(k) & sp, "un " & gros(k + 5) & sp): GoTo fin
If D <> "" And C = "un" Then mydz = "cent" & sp
If D <> "" And C <> "" And C <> "un" Then mydz = C & sp & "cent" + sp
myct = D & sp & gros(k) & sp
fin:
t2 = mydz & myct
t = t & mydz & myct
mydz = "": myct = ""
gp = gp + 3
Next
D = a(centime)
If t <> "" Then myct = IIf(centime = 1, " centime", " centimes")
If t = "" Then myct = IIf(centime = 1, " centime d'Euro", " centimes d'Euro")
If centime = 0 Then D = "": myct = ""
Chiffrelettre = t & D & myct
End Function
gdd le 30 juin 2009 à 22h17
Bonjour,

Pour écrire un nombre en toute lettres, il existe des fichiers de convertion que vous trouverez en faisant une recherche sur "Nb2Words" et celui d'Excel s'appelle "NombresEnLettres.xla" ; il y a également la syntaxe pour écrire la formule. Le fichier devra être déclaré ensuite dans les macros complémentaires. Je n'ai plus sous la main l'adresse pour la recherche.

Voir aussi à http://bvrve.club.fr/Astuces_Michel/accueil.htm
fdatch le 30 juin 2009 à 22h34
Bonsoir,
Voici un petit utilitaire de Cathy astuces
http://www.cathyastuce.com/applications/presentation.php#macroxl

Je l'ai essayé, ça marche !!
Suivre le fichier texte dans le dossier Zip pour ajouter cette macro dans ton Excel.

Cordialement.
gdd le 30 juin 2009 à 22h35
re Bonjour,

Je viens de trouver nb2words à l'adresse http://frederic.sigonneau.free.fr/ToutFait.htm
puis cliquer sur l'icone verte nb2words.exe
Ça devrait faire votre bonheur.
Quenlutincile le 23 juillet 2009 à 15h08
willyplaisir a écrit :
bonjour,

....


Bonjour willyplaisir et aux autres qui m'avez apporté une réponse.


J'ai pris longuement du temps pour me lancer et j'ai enfin essayé la solution de willyplaisir que me parraît la plus simple à mettre en oeuvre.
Cela fonctionne très bien et c'est très efficace pour les valeurs en euros. :bien:

Par contre, pour les nombres (non euros) et pour les années, ce n'est pas tout à fait convaiquant car il y a toujours "Euros" et "centimes" à la fin. :(
Peut-on avoir quelque chose pour des chiffres seuls tel que :
- deux mille neuf (pour 2009)
- cent vingt cinq virgule douze (pour 125.12)
- cent vingt cinq virgule zéro deux (pour 125.02)

Merci d'avance
A+
willyplaisir le 23 juillet 2009 à 18h22
:hello:
comme je n'ai pas trop le temps de modifier la macro ci-dessus, je te propose celle ci:
ConvNumberLetter()


Option Explicit


'***********
' Devise=0 aucune
' =1 Euro €
' =2 Dollar $
' =3 €uro €
' Langue=0 Français
' =1 Belgique
' =2 Suisse
' Casse =0 Minuscule
' =1 Majuscule en début de phrase
' =2 Majuscule
' =3 Majuscule en début de chaque mot
' ZeroCent=0 Ne mentionne pas les cents s'ils sont égal à 0
' =1 Mentionne toujours les cents
'***********
' 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, _
Optional Casse As Byte = 0, _
Optional ZeroCent 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 dblEnt >= 1000000 And Right(dblEnt, 6) = "000000" Then strDev = " d'Euro"
If byDec > 0 Then strCentimes = strCentimes & " Cent"
If byDec > 1 Then strCentimes = strCentimes & "s"
Case 2
strDev = " Dollar"
If byDec > 0 Then strCentimes = strCentimes & " Cent"
Case 3
strDev = " €uro"
If dblEnt >= 1000000 And Right(dblEnt, 6) = "000000" Then strDev = " d'€uro"
If byDec > 0 Then strCentimes = strCentimes & " Cent"
If byDec > 1 Then strCentimes = strCentimes & "s"
End Select
If dblEnt > 1 And Devise <> 0 Then strDev = strDev & "s"
strDev = strDev & " "
If dblEnt = 0 Then
ConvNumberLetter = "zéro " & strDev
Else
ConvNumberLetter = ConvNumEnt(CDbl(dblEnt), Langue) & strDev
End If
If byDec = 0 Then
If Devise <> 0 Then
If ZeroCent = 1 Then ConvNumberLetter = ConvNumberLetter & "zéro Cent"
End If
Else
If Devise = 0 Then
ConvNumberLetter = ConvNumberLetter & _
ConvNumDizaine(byDec, Langue, True) & strCentimes
Else
ConvNumberLetter = ConvNumberLetter & _
ConvNumDizaine(byDec, Langue, False) & strCentimes
End If
End If
ConvNumberLetter = Replace(ConvNumberLetter, " ", " ")
If Left(ConvNumberLetter, 1) = " " Then ConvNumberLetter = _
Right(ConvNumberLetter, Len(ConvNumberLetter) - 1)
If Right(ConvNumberLetter, 1) = " " Then ConvNumberLetter = _
Left(ConvNumberLetter, Len(ConvNumberLetter) - 1)
Select Case Casse
Case 0
ConvNumberLetter = LCase(ConvNumberLetter)
Case 1
ConvNumberLetter = UCase(Left(ConvNumberLetter, 1)) & _
LCase(Right(ConvNumberLetter, Len(ConvNumberLetter) - 1))
Case 2
ConvNumberLetter = UCase(ConvNumberLetter)
Case 3
ConvNumberLetter = Application.WorksheetFunction.Proper(ConvNumberLetter)
If Devise = 3 Then _
ConvNumberLetter = Replace(ConvNumberLetter, "€Uros", "€uros", , , vbTextCompare)
End Select
End Function

Private Function ConvNumEnt(Nombre As Double, Langue As Byte)
Dim iTmp As Variant, dblReste As Double
Dim strTmp As String
Dim iCent As Integer, iMille As Integer, iMillion As Integer
Dim iMilliard As Integer, iBillion As Integer

iTmp = Nombre - (Int(Nombre / 1000) * 1000)
iCent = CInt(iTmp)
ConvNumEnt = Nz(ConvNumCent(iCent, Langue))
dblReste = Int(Nombre / 1000)
If iTmp = 0 And dblReste = 0 Then Exit Function
iTmp = dblReste - (Int(dblReste / 1000) * 1000)
If iTmp = 0 And dblReste = 0 Then Exit Function
iMille = CInt(iTmp)
strTmp = ConvNumCent(iMille, Langue)
Select Case iTmp
Case 0
Case 1
strTmp = " mille "
Case Else
strTmp = strTmp & " mille "
End Select
If iMille = 0 And iCent > 0 Then ConvNumEnt = "et " & ConvNumEnt
ConvNumEnt = Nz(strTmp) & ConvNumEnt
dblReste = Int(dblReste / 1000)
iTmp = dblReste - (Int(dblReste / 1000) * 1000)
If iTmp = 0 And dblReste = 0 Then Exit Function
iMillion = CInt(iTmp)
strTmp = ConvNumCent(iMillion, Langue)
Select Case iTmp
Case 0
Case 1
strTmp = strTmp & " million "
Case Else
strTmp = strTmp & " millions "
End Select
If iMille = 1 Then ConvNumEnt = "et " & ConvNumEnt
ConvNumEnt = Nz(strTmp) & ConvNumEnt
dblReste = Int(dblReste / 1000)
iTmp = dblReste - (Int(dblReste / 1000) * 1000)
If iTmp = 0 And dblReste = 0 Then Exit Function
iMilliard = CInt(iTmp)
strTmp = ConvNumCent(iMilliard, Langue)
Select Case iTmp
Case 0
Case 1
strTmp = strTmp & " milliard "
Case Else
strTmp = strTmp & " milliards "
End Select
If iMillion = 1 Then ConvNumEnt = "et " & ConvNumEnt
ConvNumEnt = Nz(strTmp) & ConvNumEnt
dblReste = Int(dblReste / 1000)
iTmp = dblReste - (Int(dblReste / 1000) * 1000)
If iTmp = 0 And dblReste = 0 Then Exit Function
iBillion = CInt(iTmp)
strTmp = ConvNumCent(iBillion, Langue)
Select Case iTmp
Case 0
Case 1
strTmp = strTmp & " billion "
Case Else
strTmp = strTmp & " billions "
End Select
If iMilliard = 1 Then ConvNumEnt = "et " & ConvNumEnt
ConvNumEnt = Nz(strTmp) & ConvNumEnt
End Function

Private Function ConvNumDizaine(Nombre As Byte, Langue As Byte, bDec As Boolean) As String
Dim TabUnit As Variant, TabDiz As Variant
Dim byUnit As Byte, byDiz As Byte
Dim strLiaison As String

If bDec Then
TabDiz = Array("zéro", "", "vingt", "trente", "quarante", "cinquante", _
"soixante", "soixante", "quatre-vingt", "quatre-vingt")
Else
TabDiz = Array("", "", "vingt", "trente", "quarante", "cinquante", _
"soixante", "soixante", "quatre-vingt", "quatre-vingt")
End If
If Nombre = 0 Then
TabUnit = Array("zéro")
Else
TabUnit = Array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept", _
"huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", _
"seize", "dix-sept", "dix-huit", "dix-neuf")
End If
If Langue = 1 Then
TabDiz(7) = "septante"
TabDiz(9) = "nonante"
ElseIf Langue = 2 Then
TabDiz(7) = "septante"
TabDiz(8) = "huitante"
TabDiz(9) = "nonante"
End If
byDiz = Int(Nombre / 10)
byUnit = Nombre - (byDiz * 10)
strLiaison = "-"
If byUnit = 1 Then strLiaison = " et "
Select Case byDiz
Case 0
strLiaison = " "
Case 1
byUnit = byUnit + 10
strLiaison = ""
Case 7
If Langue = 0 Then byUnit = byUnit + 10
Case 8
If Langue <> 2 Then strLiaison = "-"
Case 9
If Langue = 0 Then
byUnit = byUnit + 10
strLiaison = "-"
End If
End Select
ConvNumDizaine = TabDiz(byDiz)
If byDiz = 8 And Langue <> 2 And byUnit = 0 Then ConvNumDizaine = ConvNumDizaine & "s"
If TabUnit(byUnit) <> "" Then
ConvNumDizaine = ConvNumDizaine & strLiaison & TabUnit(byUnit)
Else
ConvNumDizaine = ConvNumDizaine
End If
End Function

Private Function ConvNumCent(Nombre As Integer, Langue As Byte) As String
Dim TabUnit As Variant
Dim byCent As Byte, byReste As Byte
Dim strReste As String

TabUnit = Array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept", _
"huit", "neuf", "dix")
byCent = Int(Nombre / 100)
byReste = Nombre - (byCent * 100)
strReste = ConvNumDizaine(byReste, Langue, False)
Select Case byCent
Case 0
ConvNumCent = strReste
Case 1
If byReste = 0 Then
ConvNumCent = "cent"
Else
ConvNumCent = "cent " & strReste
End If
Case Else
If byReste = 0 Then
ConvNumCent = TabUnit(byCent) & " cents"
Else
ConvNumCent = TabUnit(byCent) & " cent " & strReste
End If
End Select
End Function

Private Function Nz(strNb As String) As String
If strNb <> " zéro" Then Nz = strNb
End Function


et fais un test :salut:
Quenlutincile le 24 juillet 2009 à 11h08
Bonjour,

Super cela fonctionne. De plus on peut choisir une mise en forme. :bien:

Je n'y serai jamais arrivé san ton aide.
Merci encore.

A+ :salut:
-->Message édité par Quenlutincile le 24/07/2009 11:12:04<--
willyplaisir le 24 juillet 2009 à 13h04
:hello:
suis ravi que cela te convienne, mais j'ai utilisé le lien fourni par Fdatch.
:salut:
-->Message édité par willyplaisir le 24/07/2009 13:04:38<--
fdatch le 24 juillet 2009 à 14h46
Bonjour à tous,

Merci willyplaisir de me citer dans ton post.
En fait la macro est toute faite dans les liens du site Cathy Astuces...
Il suffit de suivre ses instructions dans le fichier .txt fourni avec cette astuce, c'est très simple !!

Cordialement.


À PROPOS DU FORUM MICRO HEBDO

LES FORUMS THÉMATIQUES ET TECHNIQUES

LES FORUMS GÉNÉRAUX

ARCHIVES DU FORUM

publicité
01Informatique
01 INFORMATIQUE
L'hebdo de référence des décideurs informatiques.
Micro Hebdo
MICRO HEBDO
L'hebdo qui vous simplifie la micro
et Internet.
L'Ordinateur Individuel
L'ORDINATEUR INDIVIDUEL
Le mensuel informatique qui vous informe et vous conseille.
Nous contacter  |  Charte de confiance  |  Voir notice légale

01net.  -  01men  -  RMC  -  BFM Radio  -  BFM TV  -  TousLesPodcasts  -  01informatique.fr  -  Association RMC-BFM
Tous droits réservés © 1999 - 2009 Internext - 01net.