excel数字转换英文大写金额_excel表格翻译软件[通俗易懂]

excel数字转换英文大写金额_excel表格翻译软件[通俗易懂]例:如在A1录入阿拉伯数字,在B1中插入函数“=数字转英文大写金额(A1)”

excel数字转换英文大写金额_excel表格翻译软件[通俗易懂]"

在工作中可能用到在EXCEL中输入一个数字,可以自动转换成英文金额标识。EXCEL或WPS通过VBA自定义函数可以实现。

1. 新建Excel表格

2. 按住”AIt+F11”打开VBA编辑器

3. 在VBA编辑器中单击菜单栏”插入→模块

4. 在打开的模块中输入如下代码→保存→回到excel界面:

 Function 数字转英文大写金额(ByVal MyNumber)
    Dim Dollars, Temp
    Dim DecimalPlace, Count
    ReDim Place(9) As String
    Application.Volatile True
    Place(2) = " THOUSAND "
    Place(3) = " MILLION "
    Place(4) = " BILLION "
    Place(5) = " TRILLION "
    MyNumber = Trim(Str(MyNumber))
    DecimalPlace = InStr(MyNumber, ".")
    If DecimalPlace > 0 Then
        Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2))
        MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
        End If
    Count = 1
    Do While MyNumber <> ""
       Temp = GetHundreds(Right(MyNumber, 3))
       If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
          If Len(MyNumber) > 3 Then
             MyNumber = Left(MyNumber, Len(MyNumber) - 3)
             Else
            MyNumber = ""
            End If
            Count = Count + 1
            Loop
    Select Case Dollars
        Case ""
            Dollars = ""
        Case "One"
            Dollars = "One Dollar"
        Case Else
            Dollars = "ASY US DOLLARS " & Dollars & " ONLY"  '/* 注释:&前、后可增加内容 */'
    End Select
    数字转英文大写金额 = Dollars
    End Function
Function GetHundreds(ByVal MyNumber)
    Dim Result As String
    If Val(MyNumber) = 0 Then Exit Function
    MyNumber = Right("000" & MyNumber, 3)
    If Mid(MyNumber, 1, 1) <> "0" Then
        Result = GetDigit(Mid(MyNumber, 1, 1)) & " HUNDRED "
        End If
    If Mid(MyNumber, 2, 1) <> "0" Then
        Result = Result & GetTens(Mid(MyNumber, 2))
        Else
        Result = Result & GetDigit(Mid(MyNumber, 3))
        End If
    GetHundreds = Result
    End Function
Function GetTens(TensText)
    Dim Result As String
    Result = ""
    If Val(Left(TensText, 1)) = 1 Then
        Select Case Val(TensText)
        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(TensText, 1))
            Case 2: Result = "AND TWENTY "
            Case 3: Result = "AND THIRTY "
            Case 4: Result = "AND FORTY "
            Case 5: Result = "AND FIFTY "
            Case 6: Result = "AND SIXTY "
            Case 7: Result = "AND SEVENTY "
            Case 8: Result = "AND EIGHTY "
            Case 9: Result = "AND NINETY "
            Case Else
        End Select
         Result = Result & GetDigit _
            (Right(TensText, 1))
            End If
      GetTens = Result
      End Function
Function GetDigit(Digit)
    Select Case Val(Digit)
        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

*代码来自网络

5. EXCEL插入函数,或选择类别-用户自定义-“数字转英文大写金额”这个函数,引用即可。

例:如在A1录入阿拉伯数字,在B1中插入函数“=数字转英文大写金额(A1)”。

今天的文章excel数字转换英文大写金额_excel表格翻译软件[通俗易懂]分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/85608.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注