Przejdź do głównej zawartości

Jak szybko przekonwertować liczby na angielskie słowa w programie Excel?

Jeśli masz kolumnę wartości liczbowych w arkuszu, a teraz musisz przekonwertować je na odpowiadające im angielskie słowa lub angielskie słowa walutowe, jak pokazano na zrzucie ekranu. Tutaj opowiem o tym, jak szybko i łatwo zmienić liczby na angielskie słowa.

Konwertuj liczby na angielskie słowa za pomocą funkcji zdefiniowanej przez użytkownika

Konwertuj liczby na słowa walutowe za pomocą funkcji zdefiniowanej przez użytkownika

Konwertuj liczby na słowa walutowe za pomocą przydatnej funkcji


Konwertuj liczby na angielskie słowa za pomocą funkcji zdefiniowanej przez użytkownika

Nie ma żadnych funkcji ani formuł, które mogłyby pomóc w rozwiązaniu tego zadania bezpośrednio w programie Excel, ale można utworzyć funkcję zdefiniowaną przez użytkownika, aby ją zakończyć. Wykonaj następujące czynności:

1. Przytrzymaj przycisk ALT + F11 klucze i otwiera plik Okno Microsoft Visual Basic for Applications.

2. Kliknij wstawka > Modułi wklej następujący kod w Okno modułu.

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. Zapisz i zamknij ten kod i wróć do arkusza roboczego, w pustej komórce wprowadź tę formułę = Liczba do słów (A2)( A2 to komórka, którą chcesz przekonwertować na angielskie słowo), zobacz zrzut ekranu:

4. Następnie naciśnij Wchodzę i wybierz komórkę C2, a następnie przeciągnij uchwyt wypełniania do zakresu, w którym chcesz zawrzeć tę formułę. Wszystkie wartości liczbowe zostały przekonwertowane na odpowiadające im angielskie słowa.

Note: Ten kod działa tylko dla liczb całkowitych, ale nie ma zastosowania do liczb dziesiętnych.


Konwertuj liczby na słowa walutowe za pomocą funkcji zdefiniowanej przez użytkownika

Jeśli chcesz przekonwertować liczby na angielskie słowa walutowe, zastosuj poniższy kod VBA.

1. Przytrzymaj przycisk ALT + F11 klucze i otwiera plik Okno Microsoft Visual Basic for Applications.

2. Kliknij wstawka > Modułi wklej następujący kod w Okno modułu.

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. Zapisz ten kod i wróć do arkusza roboczego, w pustej komórce wprowadź tę formułę = SpellNumberToEnglish (A2)( A2 to komórka, którą chcesz przekonwertować na angielskie słowo walutowe), a następnie przeciągnij uchwyt wypełniania w dół do komórek, do których chcesz zastosować tę formułę, wszystkie liczby zostały przeliterowane na angielskie słowa walutowe, patrz zrzut ekranu:


Konwertuj liczby na słowa walutowe za pomocą przydatnej funkcji

Powyższy kod jest nieco kłopotliwy dla początkujących użytkowników Excela, tutaj przedstawię przydatną funkcję, Kutools dla programu Excel's Liczby na słowa, dzięki temu narzędziu możesz szybko przeliterować liczby na angielskie słowa lub słowa walutowe.

Porady:Aby to zastosować Liczby na słowa Po pierwsze, należy pobrać plik Kutools dla programu Excel, a następnie szybko i łatwo zastosuj tę funkcję.

Po zainstalowaniu Kutools dla programu Excel, zrób tak:

1. Wybierz listę liczb, które chcesz przekonwertować, a następnie kliknij Kutools > Treść > Liczby na słowazobacz zrzut ekranu:

2, w Liczby na słowa walutowe okno dialogowe, zaznacz Angielski opcja z Języki listę, a następnie kliknij Ok przycisk, zobaczysz, że wszystkie liczby zostały przeliterowane na angielskie słowa walutowe:

Tips: Jeśli chcesz poznać angielskie słowa, sprawdź Nie przeliczono na walutę pole wyboru z Opcje sekcja, zobacz zrzuty ekranu:

Kliknij, aby pobrać Kutools dla programu Excel i bezpłatną wersję próbną teraz!

Najlepsze narzędzia biurowe

🤖 Pomocnik AI Kutools: Zrewolucjonizuj analizę danych w oparciu o: Inteligentne wykonanie   |  Wygeneruj kod  |  Twórz niestandardowe formuły  |  Analizuj dane i generuj wykresy  |  Wywołaj funkcje Kutools...
Popularne funkcje: Znajdź, wyróżnij lub zidentyfikuj duplikaty   |  Usuń puste wiersze   |  Łącz kolumny lub komórki bez utraty danych   |   Okrągły bez wzoru ...
Super wyszukiwanie: Wiele kryteriów VLookup    Wiele wartości VLookup  |   Przeglądanie pionowe na wielu arkuszach   |   Wyszukiwanie rozmyte ....
Zaawansowana lista rozwijana: Szybko twórz listę rozwijaną   |  Zależna lista rozwijana   |  Lista rozwijana wielokrotnego wyboru ....
Menedżer kolumn: Dodaj określoną liczbę kolumn  |  Przesuń kolumny  |  Przełącz stan widoczności ukrytych kolumn  |  Porównaj zakresy i kolumny ...
Polecane funkcje: Fokus siatki   |  Widok projektu   |   Duży pasek formuły    Menedżer skoroszytów i arkuszy   |  Biblioteka zasobów (Automatyczny tekst)   |  Selektor dat   |  Połącz arkusze   |  Szyfruj/odszyfruj komórki    Wysyłaj e-maile według listy   |  Super filtr   |   Specjalny filtr (filtruj pogrubienie/kursywa/przekreślenie...) ...
15 najlepszych zestawów narzędzi12 Tekst Tools (Dodaj tekst, Usuń znaki, ...)   |   50 + Wykres rodzaje (Wykres Gantta, ...)   |   40+ Praktyczne Wzory (Oblicz wiek na podstawie urodzin, ...)   |   19 Wprowadzenie Tools (Wstaw kod QR, Wstaw obraz ze ścieżki, ...)   |   12 Konwersja Tools (Liczby na słowa, Przeliczanie walut, ...)   |   7 Połącz i podziel Tools (Zaawansowane wiersze łączenia, Podział komórki, ...)   |   ... i więcej

Zwiększ swoje umiejętności Excela dzięki Kutools for Excel i doświadcz wydajności jak nigdy dotąd. Kutools dla programu Excel oferuje ponad 300 zaawansowanych funkcji zwiększających produktywność i oszczędzających czas.  Kliknij tutaj, aby uzyskać funkcję, której najbardziej potrzebujesz...

Opis


Karta Office wprowadza interfejs z zakładkami do pakietu Office i znacznie ułatwia pracę

  • Włącz edycję i czytanie na kartach w programach Word, Excel, PowerPoint, Publisher, Access, Visio i Project.
  • Otwieraj i twórz wiele dokumentów w nowych kartach tego samego okna, a nie w nowych oknach.
  • Zwiększa produktywność o 50% i redukuje setki kliknięć myszką każdego dnia!
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