跳到主要内容

如何在Excel中将货币转换为单词文本?

对于使用英语作为第二语言的非母语使用者,有时当数字过长时,很难直接将货币编号更改为英语单词。 在本文中,您将学习如何在Excel中轻松地将货币转换为单词文本。

使用VBA代码将货币转换为单词
使用 Kutools for Excel 将货币转换为单词


使用VBA代码将货币转换为单词

使用下面的VBA代码,您可以将货币编号转换为英文单词。

1。 按 其他 + F11 打开 Microsoft Visual Basic应用程序 对话框。

2.在 Microsoft Visual Basic应用程序 对话框,单击 插页 > 模块。 然后将以下代码复制并粘贴到代码窗口中。

VBA代码:将货币编号转换为英文单词

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。 按 其他 + Q 同时关闭按键 Microsoft Visual Basic应用程序 对话框。

4.选择与要转换为单词的单元格相邻的空白单元格(B1),然后输入公式 = NumberstoWords(A1),然后按 输入 键。

备注:A1是包含货币编号的单元格。 您可以根据需要进行更改。

5.选择单元格B1,向下拖动Fill Handle以获取货币编号的所有英文单词。


使用 Kutools for Excel 将货币转换为单词

如此长的VBA代码似乎很复杂。 在这里,我将向您介绍一个方便的实用程序,可以轻松解决此问题。 随着 小写金额转大写 实用程序 Kutools for Excel,将货币转换为文字将不再是问题。 请执行以下操作。

申请前 Kutools for Excel首先下载并安装.

1.选择包含您要转换的货币编号的单元格。

2。 点击 库工具 > 内容 > 小写金额转大写。 看截图:

3.在 数字到货币单词 对话框中选择 英语 选项,然后单击 OK or 使用 按钮。

现在,所选的货币数字将立即转换为英语单词。

  如果您想免费试用(30天)此实用程序, 请点击下载,然后按照上述步骤进行操作。

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
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