Come convertire il testo delle valute in parole in Excel?
Per i non madrelingua che utilizzano l'inglese come seconda lingua, a volte è difficile convertire direttamente un numero di valuta in parole inglesi quando il numero è troppo lungo. In questo articolo, imparerai come convertire facilmente la valuta in testo in parole in Excel.
Converti valuta in parole con il codice VBA
Converti valuta in parole con Kutools per Excel
Converti valuta in parole con il codice VBA
Con il seguente codice VBA, puoi convertire un numero di valuta in parole inglesi.
1. Premi Alt + F11 per aprire la finestra di dialogo Microsoft Visual Basic for Applications.
2. Nella finestra di dialogo Microsoft Visual Basic for Applications, fai clic su Inserisci > Modulo. Poi copia e incolla il codice sottostante nella finestra del codice.
Codice VBA: Converti numero di valuta in parole inglesi
Function NumberstoWords(ByVal pNumber)
Dim Dollars, Cents
arr = Array("", "", " Thousand ", " Million ", " Billion ", " Trillion ")
pNumber = Trim(Str(pNumber))
xDecimal = InStr(pNumber, ".")
If xDecimal > 0 Then
Cents = GetTens(Left(Mid(pNumber, xDecimal + 1) & "00", 2))
pNumber = Trim(Left(pNumber, xDecimal - 1))
End If
xIndex = 1
Do While pNumber <> ""
xHundred = ""
xValue = Right(pNumber, 3)
If Val(xValue) <> 0 Then
xValue = Right("000" & xValue, 3)
If Mid(xValue, 1, 1) <> "0" Then
xHundred = GetDigit(Mid(xValue, 1, 1)) & " Hundred "
End If
If Mid(xValue, 2, 1) <> "0" Then
xHundred = xHundred & GetTens(Mid(xValue, 2))
Else
xHundred = xHundred & GetDigit(Mid(xValue, 3))
End If
End If
If xHundred <> "" Then
Dollars = xHundred & arr(xIndex) & Dollars
End If
If Len(pNumber) > 3 Then
pNumber = Left(pNumber, Len(pNumber) - 3)
Else
pNumber = ""
End If
xIndex = xIndex + 1
Loop
Select Case Dollars
Case ""
Dollars = "No Dollars"
Case "One"
Dollars = "One Dollar"
Case Else
Dollars = Dollars & " Dollars"
End Select
Select Case Cents
Case ""
Cents = " and No Cents"
Case "One"
Cents = " and One Cent"
Case Else
Cents = " and " & Cents & " Cents"
End Select
NumberstoWords = Dollars & Cents
End Function
Function GetTens(pTens)
Dim Result As String
Result = ""
If Val(Left(pTens, 1)) = 1 Then
Select Case Val(pTens)
Case 10: Result = "Ten"
Case 11: Result = "Eleven"
Case 12: Result = "Twelve"
Case 13: Result = "Thirteen"
Case 14: Result = "Fourteen"
Case 15: Result = "Fifteen"
Case 16: Result = "Sixteen"
Case 17: Result = "Seventeen"
Case 18: Result = "Eighteen"
Case 19: Result = "Nineteen"
Case Else
End Select
Else
Select Case Val(Left(pTens, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
Case 4: Result = "Forty "
Case 5: Result = "Fifty "
Case 6: Result = "Sixty "
Case 7: Result = "Seventy "
Case 8: Result = "Eighty "
Case 9: Result = "Ninety "
Case Else
End Select
Result = Result & GetDigit(Right(pTens, 1))
End If
GetTens = Result
End Function
Function GetDigit(pDigit)
Select Case Val(pDigit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four"
Case 5: GetDigit = "Five"
Case 6: GetDigit = "Six"
Case 7: GetDigit = "Seven"
Case 8: GetDigit = "Eight"
Case 9: GetDigit = "Nine"
Case Else: GetDigit = ""
End Select
End Function
3. Premi contemporaneamente i tasti Alt + Q per chiudere la finestra di dialogo Microsoft Visual Basic for Applications.
4. Seleziona una cella vuota (B1) adiacente alla cella che desideri convertire in parole, inserisci la formula =NumberstoWords(A1), quindi premi il tasto Invio.
Nota: A1 è la cella che contiene il numero di valuta. Puoi modificarla secondo necessità.
5. Seleziona la cella B1, trascina la maniglia di riempimento verso il basso per ottenere tutte le parole inglesi dei numeri di valuta.
Converti valuta in parole con Kutools per Excel
Questo lungo codice VBA sembra complicato. Qui ti presenterò un'utilità pratica per risolvere facilmente questo problema. Con l'utilità Numeri in Parole di Kutools per Excel, convertire la valuta in parole non sarà più un problema. Procedi come segue.
Prima di applicare Kutools per Excel, scarica e installalo prima.
1. Seleziona le celle con i numeri di valuta che desideri convertire.
2. Clicca su Kutools > Testo > Numeri in Parole. Vedi screenshot:
3. Nella finestra di dialogo Numeri in Parole di Valuta, seleziona l'opzione Inglese, e fai clic sul pulsante OK o Applica.
Ora i numeri di valuta selezionati vengono immediatamente convertiti in parole inglesi.
Kutools per Excel - Potenzia Excel con oltre 300 strumenti essenziali. Goditi funzionalità AI gratuite per sempre! Ottienilo ora
I migliori strumenti per la produttività in Office
Migliora le tue competenze su Excel con Kutools per Excel e sperimenta un nuovo livello di efficienza. Kutools per Excel offre oltre300 funzionalità avanzate per aumentare la produttività e risparmiare tempo. Clicca qui per ottenere la funzione di cui hai più bisogno...
Office Tab porta l’interfaccia a schede su Office, rendendo il tuo lavoro molto più semplice
- Abilita la modifica a schede e la lettura in Word, Excel, PowerPoint, Publisher, Access, Visio e Project.
- Apri e crea più documenti in nuove schede della stessa finestra, invece che in nuove finestre.
- Aumenta la tua produttività del50% e ti fa risparmiare centinaia di clic ogni giorno!