Salt la conținutul principal

Cum se convertesc rapid numere în cuvinte în limba engleză în Excel?

Dacă aveți o coloană de valori numerice într-o foaie de lucru și acum trebuie să le convenți la cuvintele lor echivalente în limba engleză sau cuvintele în monedă engleză, după cum se arată în următoarea captură de ecran. Aici voi vorbi despre cum să schimbați numerele în cuvinte în limba engleză rapid și ușor.

Conversia numerelor în cuvinte în limba engleză cu funcția definită de utilizator

Convertiți numerele în cuvinte valutare cu funcția definită de utilizator

Convertiți numerele în cuvinte valutare cu o caracteristică utilă


Conversia numerelor în cuvinte în limba engleză cu funcția definită de utilizator

Nu există caracteristici sau formule care vă pot ajuta să rezolvați această sarcină direct în Excel, dar puteți crea o funcție definită de utilizator pentru a o termina. Vă rugăm să efectuați următorii pași:

1. Țineți apăsată tasta ALT + F11 tastele și deschide fișierul Fereastra Microsoft Visual Basic pentru aplicații.

2. Clic Insera > Moduleși lipiți următorul cod în Fereastra modulului.

Function NumberstoWords(ByVal MyNumber)
'Update by Extendoffice
Dim xStr As String
Dim xFNum As Integer
Dim xStrPoint
Dim xStrNumber
Dim xPoint As String
Dim xNumber As String
Dim xP() As Variant
Dim xDP
Dim xCnt As Integer
Dim xResult, xT As String
Dim xLen As Integer
On Error Resume Next
xP = Array("", "Thousand ", "Million ", "Billion ", "Trillion ", " ", " ", " ", " ")
xNumber = Trim(Str(MyNumber))
xDP = InStr(xNumber, ".")
xPoint = ""
xStrNumber = ""
If xDP > 0 Then
xPoint = " point "
xStr = Mid(xNumber, xDP + 1)
xStrPoint = Left(xStr, Len(xNumber) - xDP)
For xFNum = 1 To Len(xStrPoint)
xStr = Mid(xStrPoint, xFNum, 1)
xPoint = xPoint & GetDigits(xStr) & " "
Next xFNum
xNumber = Trim(Left(xNumber, xDP - 1))
End If
xCnt = 0
xResult = ""
xT = ""
xLen = 0
xLen = Int(Len(Str(xNumber)) / 3)
If (Len(Str(xNumber)) Mod 3) = 0 Then xLen = xLen - 1
Do While xNumber <> ""
If xLen = xCnt Then
xT = GetHundredsDigits(Right(xNumber, 3), False)
Else
If xCnt = 0 Then
xT = GetHundredsDigits(Right(xNumber, 3), True)
Else
xT = GetHundredsDigits(Right(xNumber, 3), False)
End If
End If
If xT <> "" Then
xResult = xT & xP(xCnt) & xResult
End If
If Len(xNumber) > 3 Then
xNumber = Left(xNumber, Len(xNumber) - 3)
Else
xNumber = ""
End If
xCnt = xCnt + 1
Loop
xResult = xResult & xPoint
NumberstoWords = xResult
End Function
Function GetHundredsDigits(xHDgt, xB As Boolean)
Dim xRStr As String
Dim xStrNum As String
Dim xStr As String
Dim xI As Integer
Dim xBB As Boolean
xStrNum = xHDgt
xRStr = ""
On Error Resume Next
xBB = True
If Val(xStrNum) = 0 Then Exit Function
xStrNum = Right("000" & xStrNum, 3)
xStr = Mid(xStrNum, 1, 1)
If xStr <> "0" Then
xRStr = GetDigits(Mid(xStrNum, 1, 1)) & "Hundred "
Else
If xB Then
xRStr = "and "
xBB = False
Else
xRStr = " "
xBB = False
End If
End If
If Mid(xStrNum, 2, 2) <> "00" Then
xRStr = xRStr & GetTenDigits(Mid(xStrNum, 2, 2), xBB)
End If
GetHundredsDigits = xRStr
End Function
Function GetTenDigits(xTDgt, xB As Boolean)
Dim xStr As String
Dim xI As Integer
Dim xArr_1() As Variant
Dim xArr_2() As Variant
Dim xT As Boolean
xArr_1 = Array("Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen ")
xArr_2 = Array("", "", "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety ")
xStr = ""
xT = True
On Error Resume Next
If Val(Left(xTDgt, 1)) = 1 Then
xI = Val(Right(xTDgt, 1))
If xB Then xStr = "and "
xStr = xStr & xArr_1(xI)
Else
xI = Val(Left(xTDgt, 1))
If Val(Left(xTDgt, 1)) > 1 Then
If xB Then xStr = "and "
xStr = xStr & xArr_2(Val(Left(xTDgt, 1)))
xT = False
End If
If xStr = "" Then
If xB Then
xStr = "and "
End If
End If
If Right(xTDgt, 1) <> "0" Then
xStr = xStr & GetDigits(Right(xTDgt, 1))
End If
End If
GetTenDigits = xStr
End Function
Function GetDigits(xDgt)
Dim xStr As String
Dim xArr_1() As Variant
xArr_1 = Array("Zero ", "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ")
xStr = ""
On Error Resume Next
xStr = xArr_1(Val(xDgt))
GetDigits = xStr
End Function

3. Salvați și închideți acest cod și reveniți la foaia de lucru, într-o celulă goală, introduceți această formulă = NumberstoWords (A2)( A2 este celula pe care doriți să convertiți numărul într-un cuvânt în limba engleză), consultați captura de ecran:

4. Apoi apăsați Intrați și selectați celula C2, apoi trageți mânerul de umplere în intervalul pe care doriți să îl conțineți cu această formulă. Toate valorile numerice au fost convertite în cuvintele lor corespunzătoare în limba engleză.

notițe: Acest cod funcționează numai pentru numerele întregi, dar nu se aplică numerelor zecimale.


Convertiți numerele în cuvinte valutare cu funcția definită de utilizator

Dacă doriți să convertiți numerele în cuvinte în limba engleză, ar trebui să aplicați codul VBA de mai jos.

1. Țineți apăsată tasta ALT + F11 tastele și deschide fișierul Fereastra Microsoft Visual Basic pentru aplicații.

2. Clic Insera > Moduleși lipiți următorul cod în Fereastra modulului.

Function SpellNumberToEnglish(ByVal pNumber)
'Update by Extendoffice
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
SpellNumberToEnglish = 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. Salvați acest cod și reveniți la foaia de lucru, într-o celulă goală, introduceți această formulă = SpellNumberToEnglish (A2)( A2 este celula pe care doriți să convertiți numărul într-un cuvânt în monedă engleză), apoi trageți mânerul de umplere în jos în celulele pe care doriți să le aplicați această formulă, toate numerele au fost scrise în cuvinte în monedă engleză, a se vedea captura de ecran:


Convertiți numerele în cuvinte valutare cu o caracteristică utilă

Codul de mai sus este oarecum supărător pentru începătorii Excel, aici, voi introduce o caracteristică utilă, Kutools pentru Excel's Numere la cuvinte, cu acest utilitar, puteți specifica rapid numerele în cuvinte în limba engleză sau cuvinte valutare.

Sfat:Pentru a aplica acest lucru Numere la cuvinte caracteristică, în primul rând, ar trebui să descărcați Kutools pentru Excel, apoi aplicați caracteristica rapid și ușor.

După instalare Kutools pentru Excel, vă rugăm să faceți acest lucru:

1. Selectați lista numerelor pe care doriți să le convertiți, apoi faceți clic pe Kutools > Conţinut > Numere la cuvinte, vezi captura de ecran:

2. În Numere la cuvinte valutare caseta de dialog, bifați Engleză opțiune de la Limbă casetă listă, apoi faceți clic pe Ok , veți vedea că toate numerele au fost scrise în cuvinte în limba engleză:

sfaturi: Dacă doriți să obțineți cuvintele în limba engleză, vă rugăm să verificați Nu este convertit în valută bifați caseta din Opţiuni secțiunea, vedeți capturi de ecran:

Faceți clic pentru a descărca Kutools pentru Excel și încercare gratuită acum!

Cele mai bune instrumente de productivitate de birou

🤖 Kutools AI Aide: Revoluționați analiza datelor pe baza: Execuție inteligentă   |  Generați codul  |  Creați formule personalizate  |  Analizați datele și generați diagrame  |  Invocați funcțiile Kutools...
Caracteristici populare: Găsiți, evidențiați sau identificați duplicatele   |  Ștergeți rândurile goale   |  Combinați coloane sau celule fără a pierde date   |   Rundă fără Formula ...
Super căutare: VLookup cu mai multe criterii    VLookup cu valori multiple  |   VLookup pe mai multe foi   |   Căutare fuzzy ....
Listă derulantă avansată: Creați rapid o listă derulantă   |  Listă drop-down dependentă   |  Listă derulantă cu selectare multiplă ....
Manager de coloane: Adăugați un număr specific de coloane  |  Mutați coloanele  |  Comutați starea vizibilității coloanelor ascunse  |  Comparați intervale și coloane ...
Caracteristici prezentate: Focus pe grilă   |  Vedere de proiectare   |   Big Formula Bar    Manager registru de lucru și foi   |  Biblioteca de resurse (Text automat)   |  Data Picker   |  Combinați foi de lucru   |  Criptare/Decriptare celule    Trimiteți e-mailuri după listă   |  Super Filtru   |   Filtru special (filtrează bold/italic/barat...) ...
Top 15 seturi de instrumente12 Text Instrumente (Adăuga text, Eliminați caractere,...)   |   50+ Diagramă Tipuri de (Gantt Chart,...)   |   40+ Practic Formule (Calculați vârsta pe baza zilei de naștere,...)   |   19 inserare Instrumente (Introduceți codul QR, Inserați imaginea din cale,...)   |   12 Convertire Instrumente (Numere la cuvinte, conversie valutara,...)   |   7 Merge & Split Instrumente (Rânduri combinate avansate, Celule divizate,...)   |   ... și altele

Îmbunătățiți-vă abilitățile Excel cu Kutools pentru Excel și experimentați eficiența ca niciodată. Kutools pentru Excel oferă peste 300 de funcții avansate pentru a crește productivitatea și a economisi timp.  Faceți clic aici pentru a obține funcția de care aveți cea mai mare nevoie...

Descriere


Fila Office aduce interfața cu file în Office și vă face munca mult mai ușoară

  • Activați editarea și citirea cu file în Word, Excel, PowerPoint, Publisher, Access, Visio și Project.
  • Deschideți și creați mai multe documente în filele noi ale aceleiași ferestre, mai degrabă decât în ​​ferestrele noi.
  • Vă crește productivitatea cu 50% și reduce sute de clicuri de mouse pentru dvs. în fiecare zi!
Comments (66)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello dear.
It work good but after reopening the file. function is not working. what is the reason....? it can be solved or copy paste every time while open the same file.
This comment was minimized by the moderator on the site
Hello, Sheraz,
To keep the code work correctly, you should save the workbbok as Excel Macro-Enabled Workbook format. This file format will save the vba code.
Please try, hope it can help you!
This comment was minimized by the moderator on the site
Thank you for sharing such a wonderful program.

Kindly advise, I want to convert figures into words like "515,253.33" to show as Five Hundred Fifteen Thousand Two Hundred Fifty Three and Cents Thirty Three Only. Also it should not show "Dollars"
Warm regards,
Khozema
This comment was minimized by the moderator on the site
HI SIR/MADAM,

ITS WORKING GOOD BUT I NEED ONE THINK TO ADD "LAKS & CROSE" HOW TO ADD PLESE ATTACHED THIS CODE TO ME THANKS
This comment was minimized by the moderator on the site
Thank you so much... it works awesome
This comment was minimized by the moderator on the site
What needs to be changed if i want to make the decimal place into this "and ___/100"? For examples, instead of "ONE MILLION FOUR HUNDRED THIRTY THOUSAND TWO HUNDRED FORTY FIVE PESOS AND EIGHTY ONE CENTS", i want it to be like "ONE MILLION FOUR HUNDRED THIRTY THOUSAND TWO HUNDRED FORTY FIVE PESOS AND 81/100"
This comment was minimized by the moderator on the site
Hello, Maxine
To get the result you said, please apply the below code:
After pasting the code, please apply this formula:=SpellNumberToEnglish(A2)
Function SpellNumberToEnglish(ByVal pNumber)
'Update by Extendoffice
Dim Dollars, Cents
arr = Array("", "", " Thousand ", " Million ", " Billion ", " Trillion ")
pNumber = Trim(Str(pNumber))
xDecimal = InStr(pNumber, ".")
If xDecimal > 0 Then
    Cents = Left(Mid(pNumber, xDecimal + 1) & "00", 2) & "/100" '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
SpellNumberToEnglish = Dollars & Cents
Debug.Print SpellNumberToEnglish
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


Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Hi,

Great code thanks. One question. Is it possible to save someway this module to in any new document be avilable? Or i need do this process any time if im want this in another document?

Thanks
This comment was minimized by the moderator on the site
Hello Nemeth,

Glad to help. I have a solution to your question. You can save an empty document with VBA code as Excel Add-in (*.xlam). Then you can use the add-in by clicking the Developer tab > Excel-Add-ins in Excel. Please have a try. And if you have any questions, please don't hesitate to contact us. Have a nice day.

Sincerely,
Mandy
This comment was minimized by the moderator on the site
hi, how can i do the opposite, I want to convert from ( one hundred fifty five) to (155). could you help me please?
This comment was minimized by the moderator on the site
Hi, Ghada,For converting the words to numbers, you should apply the below code:After pasting the code, please use this formula: =wordstodigits(A2)Please try, hope it can help you!<div data-tag="code">Option Explicit
Const wordDollar1 = "DOLLAR"
Const wordDollar2 = "DOLLARS"
Const oneTrillion = "TRILLION"
Const oneBillion = "BILLION"
Const oneMillion = "MILLION"
Const oneThousand = "THOUSAND"
Const oneHundred = "HUNDRED"
Dim theWords As String

Function WordsToDigits(theWordCell As Range) As Currency
Dim curPart As String
Dim theDigits As Currency
Dim Pt1 As Integer
Dim Pt2 As Integer
Dim Trillions As Currency
Dim Billions As Currency
Dim Millions As Currency
Dim Thousands As Currency
Dim Hundreds As Currency
Dim Tens As Currency
Dim Units As Currency
Dim whatGroup As String
Dim theFraction As Double
Dim hasFraction As Boolean
If IsEmpty(theWordCell) Then
Exit Function
End If
theWords = UCase(Trim(Application.WorksheetFunction.Clean(theWordCell)))
theWords = Replace(theWords, "-", " ")
theWords = Replace(theWords, "DOLLARS", " ")
theWords = Replace(theWords, "DOLLAR", " ")
Do While InStr(theWords, " ") > 0
theWords = Replace(theWords, " ", " ")
Loop
If InStr(theWords, "/") > 0 Or InStr(theWords, " AND ") > 0 Then
hasFraction = True
theFraction = CalculateTheFraction()
End If
Trillions = EvaluateGroupValue(oneTrillion)
Billions = EvaluateGroupValue(oneBillion)
Millions = EvaluateGroupValue(oneMillion)
Thousands = EvaluateGroupValue(oneThousand)
If InStr(theWords, oneHundred) > 0 Then
curPart = Left(theWords, InStr(theWords, oneHundred) + Len(oneHundred))
theWords = Right(theWords, Len(theWords) - Len(curPart))
Hundreds = GetHundreds(curPart)
End If
theWords = Trim(theWords)
Tens = GetTens(theWords)
theDigits = CCur((Trillions * 1000000000000#)) + CCur((Billions * 1000000000#)) + _
CCur((Millions * 1000000#)) + CCur((Thousands * 1000)) + CCur((Hundreds * 100)) + Tens
If hasFraction Then
theDigits = theDigits + theFraction
End If
WordsToDigits = theDigits
End Function

Private Function EvaluateGroupValue(strGroup As String) As Currency
Dim curPart As String
If InStr(theWords, strGroup) > 0 Then
curPart = Left(theWords, InStr(theWords, strGroup) + Len(strGroup))
theWords = Right(theWords, Len(theWords) - Len(curPart))
EvaluateGroupValue = GetLargeValues(curPart, strGroup)
End If
End Function

Private Function GetLargeValues(strAmount As String, strGroup As String) As Currency
Dim tempText As String
Dim theTens As String
Dim theUnits As String
tempText = Trim(Left(strAmount, InStr(strAmount, strGroup) - 1))
tempText = Replace(tempText, strGroup, "")
If InStr(tempText, " " & oneHundred) > 0 Then
tempText = Replace(tempText, " " & oneHundred, "")
If InStr(tempText, " ") > 0 Then
GetLargeValues = GetUnits(Left(tempText, InStr(tempText, " ") - 1)) * 100
tempText = Right(tempText, Len(tempText) - InStr(tempText, " "))
If InStr(tempText, " ") > 0 Then
theTens = GetUnits(Left(tempText, InStr(tempText, " ") - 1))
theUnits = GetUnits(Trim(Right(tempText, Len(tempText) - InStr(tempText, " "))))
GetLargeValues = GetLargeValues + theTens + theUnits
Else
GetLargeValues = GetLargeValues + GetUnits(tempText)
End If
Else
GetLargeValues = GetUnits(tempText) * 100
End If
Exit Function
End If
If InStr(tempText, " ") > 0 Then
GetLargeValues = GetUnits(Left(tempText, InStr(tempText, " ") - 1))
GetLargeValues = GetLargeValues + GetUnits(Right(tempText, Len(tempText) - InStr(tempText, " ")))
Else
GetLargeValues = GetUnits(tempText)
End If
End Function

Private Function GetHundreds(strAmount As String) As Integer
Dim tempText As String
tempText = Trim(Left(strAmount, InStr(strAmount, oneHundred) - 1))
If InStr(tempText, " ") > 0 Then
GetHundreds = GetUnits(Left(tempText, InStr(tempText, " ") - 1))
GetHundreds = GetHundreds + GetUnits(Right(tempText, Len(tempText) - InStr(tempText, " ")))
Else
GetHundreds = GetUnits(tempText)
End If
End Function

Private Function GetTens(strAmount As String) As Integer
Dim tempText As String
tempText = Trim(strAmount)
If InStr(tempText, " ") > 0 Then
GetTens = GetUnits(Left(tempText, InStr(tempText, " ") - 1))
GetTens = GetTens + GetUnits(Right(tempText, Len(tempText) - InStr(tempText, " ")))
Else
GetTens = GetUnits(tempText)
End If
End Function

Private Function GetUnits(strAmount As String) As Integer
Dim tempText As String
tempText = Trim(strAmount)
Select Case tempText
Case Is = "ONE"
GetUnits = 1
Case Is = "TWO"
GetUnits = 2
Case Is = "THREE"
GetUnits = 3
Case Is = "FOUR"
GetUnits = 4
Case Is = "FIVE"
GetUnits = 5
Case Is = "SIX"
GetUnits = 6
Case Is = "SEVEN"
GetUnits = 7
Case Is = "EIGHT"
GetUnits = 8
Case Is = "NINE"
GetUnits = 9
Case Is = "TEN"
GetUnits = 10
Case Is = "ELEVEN"
GetUnits = 11
Case Is = "TWELVE"
GetUnits = 12
Case Is = "THIRTEEN"
GetUnits = 13
Case Is = "FOURTEEN"
GetUnits = 14
Case Is = "FIFTEEN"
GetUnits = 15
Case Is = "SIXTEEN"
GetUnits = 16
Case Is = "SEVENTEEN"
GetUnits = 17
Case Is = "EIGHTEEN"
GetUnits = 18
Case Is = "NINETEEN"
GetUnits = 19
Case Is = "TWENTY"
GetUnits = 20
Case Is = "THIRTY"
GetUnits = 30
Case Is = "FORTY", "FOURTY"
GetUnits = 40
Case Is = "FIFTY"
GetUnits = 50
Case Is = "SIXTY"
GetUnits = 60
Case Is = "SEVENTY"
GetUnits = 70
Case Is = "EIGHTY"
GetUnits = 80
Case Is = "NINETY"
GetUnits = 90
Case Else
GetUnits = 0
End Select
End Function

Private Function CalculateTheFraction() As Double
Dim fractionPart As String
Dim tempValue As Double
Dim toPower As Integer
Dim theDivisor As Double
If InStr(theWords, " AND ") > 0 Then
fractionPart = Right(theWords, Len(theWords) - InStr(theWords, " AND ") - 4)
theWords = Left(theWords, InStr(theWords, " AND ") - 1)
End If
If InStr(fractionPart, "/") > 0 Then
tempValue = Val(fractionPart)
theDivisor = Right(fractionPart, Len(fractionPart) - InStr(fractionPart, "/"))
CalculateTheFraction = tempValue / theDivisor
Exit Function
End If
tempValue = Val(fractionPart)
toPower = Len(CStr(tempValue))
theDivisor = 10 ^ toPower
CalculateTheFraction = tempValue / theDivisor
End Function
This comment was minimized by the moderator on the site
FINE. But sorry to say that this formula is NOT working permanently ... I closed the workbook for Lunch break. After Lunch I opened the file but the formula was not working. showing error like #NAME?. Kindly intimate solutions please.
This comment was minimized by the moderator on the site
Hello, Vignesh,To keep the code work correctly, you should save the workbbok as Excel Macro-Enabled Workbook format.Please try, hope it can help you!
This comment was minimized by the moderator on the site
But sorry to say that this formula is NOT working permanently ... I closed the workbook for Lunch break. After Lunch I opened the file but the formula was not working. showing error like #NAME?. Kindly intimate solutions please.
This comment was minimized by the moderator on the site
how do I convert 1101 to One One Zero One? I don't need dollars just want actual digits.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations