Przejdź do głównej zawartości

Jak przekonwertować walutę na tekst słów w programie Excel?

W przypadku obcokrajowców, którzy używają angielskiego jako drugiego języka, czasami trudno jest bezpośrednio zmienić numer waluty na angielskie słowa, gdy liczba jest zbyt długa. W tym artykule dowiesz się, jak łatwo przekonwertować walutę na tekst słów w programie Excel.

Konwertuj walutę na słowa za pomocą kodu VBA
Konwertuj walutę na słowa za pomocą Kutools for Excel


Konwertuj walutę na słowa za pomocą kodu VBA

Za pomocą poniższego kodu VBA możesz przekonwertować numer waluty na angielskie słowa.

1. naciśnij inny + F11 otworzyć Microsoft Visual Basic for Applications okno dialogowe.

2. w Microsoft Visual Basic for Applications okno dialogowe, kliknij wstawka > Moduł. Następnie skopiuj i wklej poniższy kod do okna kodu.

Kod VBA: Konwertuj numer waluty na angielskie słowa

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. naciśnij inny + Q klawisze jednocześnie, aby zamknąć Microsoft Visual Basic for Applications okno dialogowe.

4. Wybierz pustą komórkę (B1), która sąsiaduje z komórką, którą chcesz przekonwertować na słowa, wprowadź formułę = Liczba do słów (A1), a następnie naciśnij Wchodzę klawisz.

Note: A1 to komórka zawierająca numer waluty. Możesz to zmienić według potrzeb.

5. Wybierz komórkę B1, przeciągnij uchwyt wypełnienia w dół, aby uzyskać wszystkie angielskie słowa liczb walutowych.


Konwertuj walutę na słowa za pomocą Kutools for Excel

Ten długi kod VBA wydaje się skomplikowany. Tutaj przedstawię ci przydatne narzędzie, aby łatwo rozwiązać ten problem. Dzięki Liczby na słowa użyteczność Kutools dla programu Excel, przeliczanie waluty na słowa nie będzie już problemem. Wykonaj następujące czynności.

Przed złożeniem wniosku Kutools dla programu ExcelProszę pobierz i zainstaluj najpierw.

1. Wybierz komórki z numerami walut, które chcesz przeliczyć.

2. kliknij Kutools > Treść > Liczby na słowa. Zobacz zrzut ekranu:

3. w Liczby na słowa walutowe okno dialogowe, wybierz Angielski opcję i kliknij przycisk OK or Dodaj przycisk.

Teraz wybrane numery walut są natychmiast konwertowane na angielskie słowa.

  Jeśli chcesz mieć bezpłatną wersję próbną (30 dni) tego narzędzia, kliknij, aby go pobrać, a następnie przejdź do wykonania operacji zgodnie z powyższymi krokami.

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 (19)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Write the currency AED 3862.54 in words
This comment was minimized by the moderator on the site
can convert it to malaysian ringgit ?
This comment was minimized by the moderator on the site
Hi Warsha,

This type of conversion is not supported yet. Sorry for the inconvenience.
This comment was minimized by the moderator on the site
Hello help, I love your formula but I would like to update the formula so that it stays like the example in capital letters. Thanks a lot.
Example:
USD 121,500.56 = One Hundred Twenty One Thousand Five Hundred Dollars and Fifty Six Cents
***ONE HUNDRED TWENTY ONE THOUSAND FIVE HUNDRED AND 56/100 US DOLLARS

USD 121,500.00 = One Hundred Twenty One Thousand Five Hundred Dollars and No Cents
***ONE HUNDRED TWENTY ONE THOUSAND FIVE HUNDRED AND 00/100 US DOLLARS
This comment was minimized by the moderator on the site
Hi Angel,
The following VBA code can do you a favor. After adding the code to the Module (Code) window. Don't forget to apply this formula =NumberstoWords(cell) to get the result.
Function NumberstoWords(ByVal pNumber)
'Updated by Extendoffice 20221123
Application.Volatile

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)
    Cents = "AND " & Cents & "/100 US DOLLARS"
    pNumber = Trim(Left(pNumber, xDecimal - 1))
Else
    Cents = "AND " & "00/100 US DOLLARS"
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
End Select
NumberstoWords = UCase(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
This comment was minimized by the moderator on the site
Can you update the code to use Dinar and Fils .. Fils decimal is 3 .. means it has hundreds, tens and ones..
Thank you ..
This comment was minimized by the moderator on the site
Hi Naseem,
Perhaps the VBA code on the following page can help.
Convert numbers to words using Dinar and Fils.
This comment was minimized by the moderator on the site
Thank you so much ..
Can you update the to write the fills in number not word.
125.100 --> One Hundred Twenty Five Kuwaiti Dinar and 100 Fils Only

Thanks
This comment was minimized by the moderator on the site
Want a solution that doesn't require VBA?
Check it out here
See result in screenshot
This comment was minimized by the moderator on the site
This comment was minimized by the moderator on the site
I love your macro. Found one thing that doesn't quite work well. That's when there is a fractional. For instance if a field comes up as .835 excel rounds it up but the value is typed as "eighty three cents" while excel shows .84.
Work around for this?
This comment was minimized by the moderator on the site
Hi,
Sorry for the inconvenience. We have updated the code, please give it a try.

Function NumberstoWords(ByVal pNumber)
'Updated by Extendoffice 20220428
Dim Dollars, Cents
arr = Array("", "", " Thousand ", " Million ", " Billion ", " Trillion ")
pNumber = Trim(Str(pNumber))
pNumber = Round(pNumber, 2)
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
This comment was minimized by the moderator on the site
This macro here helped me a lot, thank you so much for that. Our currency here in Kuwait has 3 digits after the decimal, could you help me with this?
This comment was minimized by the moderator on the site
If 45.67 is written as forty-five dollars, sixty-seven cents, how's 45.678 written? Is it forty-five dollars, six hundred and seventy-eight cents?
This comment was minimized by the moderator on the site
can't be changed the currency
This comment was minimized by the moderator on the site
Review the article Million billion trillion conversion beginner guideline to learn and understand about number system and number conversion.
This comment was minimized by the moderator on the site
currency is always in Dollar and cents, How can we change this to other currency?
This comment was minimized by the moderator on the site
You can change the code to your currency instead of "dollers"
This comment was minimized by the moderator on the site
Mr. Shaji can you guide with the steps Please
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations