Changer un chiffre en mot.

deudecos

XLDnaute Impliqué
Bonjour à toutes et à tous,

Bien malheureux depuis que je suis sous Mac, je ne peux plus faire de VBA, et il faut bien reconnaitre que c'était ce que j'utilisais le plus...
Je me suis donc mis aux formules par la force des choses, mais même à ce niveau, la version Mac d'excel 2008 ne me permet pas tout.
Entre autre la possibilité de transformer un nombre en mots. Ca fait un moment que je cherche mais je n'y suis pas parvenu.
Donc si c'est possible et que quelqu'un le sait... Merci d'avance.

Bonne journée

Olivier
 

Tibo

XLDnaute Barbatruc
Re : Changer un chiffre en mot.

Bonjour,

En formule, s'il s'agit de transformer en texte une valeur numérique, on peut faire :

=A1&""

S'il faut transformer un chiffre en une valeur texte particulière, il faut peut-être voir du côté de SUBSTITUE :

=SUBSTITUE(A1;1;"truc")

Pour plus de détails, joins nous un extrait de ton fichier

@+
 

deudecos

XLDnaute Impliqué
Re : Changer un chiffre en mot.

Salut Tibo,

C'est en fait beaucoup plus simple que ca, je voudrait par exemple que 1963 se transforme, après traitement en "mille neuf cent soixante trois".

Voir le fichier joint pour le cas où je me serais mal exprimé.
 

Pièces jointes

  • Deudecos.xls
    22.5 KB · Affichages: 150
  • Deudecos.xls
    22.5 KB · Affichages: 167
  • Deudecos.xls
    22.5 KB · Affichages: 165

phlaurent55

Nous a quittés en 2020
Repose en paix
Re : Changer un chiffre en mot.

Bonjour à tous,
voici la fonction que j'utilise pour transformer un nombre en texte
le résultat se donne en euros mais égalementt avec la spécificité "Belge" ( septante-------> soixante-dix)

Function ChLettres(nombre As Double) As String
Dim TRANCHE(1 To 4)
Dim ECH As Variant
Dim UNI As Variant
Dim DN As Variant
Dim DIZ As Variant

Dim N3 As Integer

If nombre >= 1000000000000# Then
ChLettres = " !!! Nombre trop grand !!!"
Exit Function
End If


ECH = Array("", "milliard", "million", "mille")
UNI = Array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf")
DN = Array("", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix-sept", "dix-huit", "dix-neuf")
DIZ = Array("", "dix", "vingt", "trente", "quarante", "cinquante", "soixante", "septante", "quatre-vingt", "nonante")



' Partie entière

If Int(nombre) = 0 Then
FIN = True
ChLettres = " zéro"
Else
FIN = False
reste = nombre
N = Format(Int(nombre), "000000000000")
J = 1
For i = 0 To 3
TRANCHE(J) = Mid(N, (i * 3) + 1, 3)
J = J + 1
Next i
T = 1
End If
While T <= 4 And FIN = False
If TRANCHE(T) > 0 Then
c = Val(Mid(TRANCHE(T), 1, 1))
D = Val(Mid(TRANCHE(T), 2, 1))
U = Val(Mid(TRANCHE(T), 3, 1))
'
' Traitement des centaines
'
Select Case c
Case 1
ChLettres = ChLettres & " " & "cent"
Case Is > 1
ChLettres = ChLettres & " " & UNI(c) & " cent"
If (D * 10) + U = 0 And T = 4 Then
ChLettres = ChLettres & "s"
FIN = True

Else
If (D * 10) + U = 0 And (T = 1 Or T = 2) Then ChLettres = ChLettres & "s"

End If
End Select
'
' Traitement des dizaines et unités
'
If FIN = False Then
Select Case D
Case 0
Select Case U
Case 1
If T = 3 Then
If c <> 0 Then
ChLettres = ChLettres & " " & UNI(U)
End If
Else
ChLettres = ChLettres & " " & UNI(U)
End If
Case Is > 1
ChLettres = ChLettres & " " & UNI(U)
End Select
Case 1
ChLettres = ChLettres & " " & DN(U + 1)
Case 2 To 6
ChLettres = ChLettres & " " & DIZ(D)
Select Case U
Case 1
ChLettres = ChLettres & " et " & UNI(U)
Case Is > 1
ChLettres = ChLettres & "-" & UNI(U)
End Select
Case 7, 9
ChLettres = ChLettres & " " & DIZ(D)
If Pays = "F" Then
Select Case D * 10 + U
Case 71
ChLettres = ChLettres & " et " & DN(U + 1)
Case Else
ChLettres = ChLettres & "-" & DN(U + 1)
End Select
Else
Select Case U
Case 1
ChLettres = ChLettres & " et " & UNI(U)
Case Is > 1
ChLettres = ChLettres & "-" & UNI(U)
End Select
End If
Case Else
ChLettres = ChLettres & " " & DIZ(D)
Select Case U
Case 0
If T = 4 Then
ChLettres = ChLettres & "s"
FIN = True

Else
If T = 1 Or T = 2 Then ChLettres = ChLettres & "s"

End If
Case Else
ChLettres = ChLettres & "-" & UNI(U)
End Select
End Select
End If

If FIN = False Then
reste = reste - TRANCHE(T) * 1000 ^ (4 - T)
Select Case T
Case 1, 2
ChLettres = ChLettres & " " & ECH(T)

If TRANCHE(T) = 1 And Int(reste) = 0 Then
ChLettres = ChLettres & " de"
FIN = True
Else
If TRANCHE(T) > 1 Then
If Int(reste) = 0 Then
ChLettres = ChLettres & "s de"
FIN = True
Else
ChLettres = ChLettres & "s"
End If
End If
End If

Case 3
ChLettres = ChLettres & " " & ECH(T)
If reste = 0 Then FIN = True
Case 4
FIN = True
End Select
End If
End If
T = T + 1
Wend

If Right(ChLettres, 5) <> " euro" Then

ChLettres = ChLettres & " euro"
End If
If Int(nombre) > 1 Then ChLettres = ChLettres & "s"


' Partie fractionnaire

N1 = nombre * 100
N2 = Int(nombre) * 100
N3 = N1 - N2
If N3 <> 0 Then
If Devise = "SD" Then
ChLettres = ChLettres & " virgule"
Else
ChLettres = ChLettres & " & "
End If
Fract = Format(N3, "00")
D = Val(Mid(Fract, 1, 1))
U = Val(Mid(Fract, 2, 1))
'
' Traitement des centièmes et dizièmes
'
Select Case D
Case 0
ChLettres = ChLettres & " " & UNI(U)
Case 1
ChLettres = ChLettres & " " & DN(U + 1)
Case 2 To 6
ChLettres = ChLettres & " " & DIZ(D)
Select Case U
Case 1
ChLettres = ChLettres & " et " & UNI(U)
Case Is > 1
ChLettres = ChLettres & "-" & UNI(U)
End Select
Case 7, 9
ChLettres = ChLettres & " " & DIZ(D)
If Pays = "F" Then
Select Case D * 10 + U
Case 71
ChLettres = ChLettres & " et " & DN(U + 1)
Case Else
ChLettres = ChLettres & "-" & DN(U + 1)
End Select
Else
Select Case U
Case 1
ChLettres = ChLettres & " et " & UNI(U)
Case Is > 1
ChLettres = ChLettres & "-" & UNI(U)
End Select
End If
Case Else
ChLettres = ChLettres & " " & DIZ(D)
Select Case U
Case 0
ChLettres = ChLettres & "s"
Case Else
ChLettres = ChLettres & "-" & UNI(U)
End Select
End Select


ChLettres = ChLettres & " cent"

If Fract > 1 Then ChLettres = ChLettres & "s"


End If
End Function



merci à l'auteur dont j'ai oublié le mon
à+
Philippe
 

deudecos

XLDnaute Impliqué
Re : Changer un chiffre en mot.

Merci pour le lien, Je crois que je vais abandonner l'idée de faire une transcription automatique parce que les moyens mis en oeuvre sont bien plus fastidieux que de le faire manuellement.
Je vais donc attendre patiemment qu'ils daignent bien réintégrer VBA dans la prochaine version d'Excel.

Merci encore

Bonne journée

Olivier
 

Discussions similaires

Statistiques des forums

Discussions
312 203
Messages
2 086 184
Membres
103 152
dernier inscrit
Karibu