如何在excel中设置公式将数字转换为英文大写金额? | 您所在的位置:网站首页 › 快速转换大写金额 › 如何在excel中设置公式将数字转换为英文大写金额? |
如何在 excel 中设置公式将数字转换为英文大写金额?
前些天有人问过转中文大写的,转英文金额有点复杂,我们一起 尝试下,先看动态效果图:
转英文金额相对于转中文金额难度要大,得自定义一个函数
1. 我们首先新建一个宏函数“数字转英文”,左下角右键“查看 代码”,在弹出的窗口中插入一个新模板,将代码粘贴上去。
2. 之后在单元格内插入函数 'fx'----' 用户定义 '-----' 数字转英文 '--- --' 确定 '! 3. 最后在需要转换英文的单元格填充好公式就可以了!
具体代码如下:
Function 数字转英文 (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 |
CopyRight 2018-2019 实验室设备网 版权所有 |