用VBA自定义一个大写金额转换的函数,在公式中输入此函数名就可以了。
具体方法:按 Alt+F11 ,在VBA编辑器菜单中点 插入→模块,将下面的函数复制到插入的模块当中,

'===================================================================

Function CChinese(StrEng As String) As String
'将阿拉伯数字转成中文字的程式例如:1560890 转成 "壹佰伍拾陆万零捌佰玖拾"。
'程式限制为不可输入超过16个数字
If Not IsNumeric(StrEng) Or StrEng Like "*.*" Or StrEng Like "*-*" Then
If Trim(StrEng) <> "" Then MsgBox "无效的数字"
CChinese = "": Exit Function
End If
Dim intLen As Integer, intCounter As Integer
Dim strCh As String, strTempCh As String
Dim strSeqCh1 As String, strSeqCh2 As String
Dim strEng2Ch As String
strEng2Ch = "零壹贰叁肆伍陆柒捌玖"
strSeqCh1 = " 拾佰仟 拾佰仟 拾佰仟 拾佰仟"
strSeqCh2 = " 万亿兆"
StrEng = CStr(CDec(StrEng))
intLen = Len(StrEng)
For intCounter = 1 To intLen
strTempCh = Mid(strEng2Ch, Val(Mid(StrEng, intCounter, 1)) + 1, 1)
If strTempCh = "零" And intLen <> 1 Then
If Mid(StrEng, intCounter + 1, 1) = "0" Or (intLen - intCounter + 1) Mod 4 = 1 Then
strTempCh = ""
End If
Else
strTempCh = strTempCh & Trim(Mid(strSeqCh1, intLen - intCounter + 1, 1))
End If
If (intLen - intCounter + 1) Mod 4 = 1 Then
strTempCh = strTempCh & Mid(strSeqCh2, (intLen - intCounter + 1) \ 4 + 1, 1)
If intCounter > 3 Then
If Mid(StrEng, intCounter - 3, 4) = "0000" Then strTempCh = Left(strTempCh, Len(strTempCh) - 1)
End If
End If
strCh = strCh & Trim(strTempCh)
Next
CChinese = strCh
End Function

'===================================================================

'===================================================================
Function daxie(money As String) As String
'实现货币金额中文大写转换的程序
'程式限制为不可输入超过16个数字
Dim x As String, y As String
Const zimu = ".sbqwsbqysbqwsbq" '定义位置代码
Const letter = "0123456789sbqwy.zjf" '定义汉字缩写
Const upcase = "零壹贰叁肆伍陆柒捌玖拾佰仟万亿圆整角分" '定义大写汉字

If CDbl(money) >= 1E+16 Then daxie = "#VALUE!": Exit Function '只能转换一亿亿元以下数目的货币!

x = Format(money, "0.00") '格式化货币
y = ""
For i = 1 To Len(x) - 3
y = y & Mid(x, i, 1) & Mid(zimu, Len(x) - 2 - i, 1)
Next
If Right(x, 3) = ".00" Then
y = y & "z"          '***元整
Else
y = y & Left(Right(x, 2), 1) & "j" & Right(x, 1) & "f"     '*元*角*分
End If
y = Replace(y, "0q", "0") '避免零千(如:40200肆万零千零贰佰)
y = Replace(y, "0b", "0") '避免零百(如:41000肆万壹千零佰)
y = Replace(y, "0s", "0") '避免零十(如:204贰佰零拾零肆)

y = Replace(y, "0j", "0") '避免零角
y = Replace(y, "0f", "") '避免零分

Do While y <> Replace(y, "00", "0")
y = Replace(y, "00", "0") '避免双零(如:1004壹仟零零肆)
Loop
y = Replace(y, "0y", "y") '避免零亿(如:210亿     贰佰壹十零亿)
y = Replace(y, "0w", "w") '避免零万(如:210万     贰佰壹十零万)
y = IIf(x < 0.1, Right(y, Len(y) - 3), y) '避免零几分(如:0.01零壹分;0.04零肆分)
y = IIf(Len(x) = 5 And Left(y, 1) = "1", Right(y, Len(y) - 1), y) '避免壹十(如:14壹拾肆;10壹拾)
y = IIf(Len(x) = 4, Replace(y, "0.", ""), Replace(y, "0.", ".")) '避免零元(如:20.00贰拾零圆;0.12零圆壹角贰分)

For i = 1 To 19
y = Replace(y, Mid(letter, i, 1), Mid(upcase, i, 1)) '大写汉字
Next
daxie = y
End Function
'===================================================================

回到Excel工作表中,若要转化A1单元格的数字,则可在其他任意单元格中输入公式 =CChinese(A1)。要转换成大写金额,则可在其他任意单元格中输入公式 =daxie(A1)。

转载于:https://blog.51cto.com/5576677/1639914

在英文版的excel中把数字转换成中文金额大写相关推荐

  1. 中文格式_财务必会Excel技巧,将数字转换成中文的5种方式

    你还在纠结如何把数字转换成中文大小写吗?下面和大家一起来学习把数字转换成中文的5种方法. 方式一:NUMBERSTRING函数 语法=NUMBERSTRING(数值,选项) 数值:被转换为中文字符串的 ...

  2. excel中的文本转换成数值

    excel中的文本转换成数值 B1 = A1*1 都乘上一个1就好了

  3. html 将数字转为汉字,怎么将wps中的数字转换成汉字 wps将数字转换汉字的步骤教程...

    在WPS编辑表格数据时,如果我们想要将表格中的数字全部转换成汉字,该如何转换?方法其实很简单,不过还有很多用户不太清楚转换方法,下面教程之家网为大家分享wps将数字转换汉字的步骤教程,不会转换的朋友可 ...

  4. JavaScript:将输入的一串数字转换成中文大写,最高可写12位(千亿)

    将输入的一串数字转换成中文大写,最高可写12位(千亿) 例:输入:10000,输出:壹万 输入:10010,输出:壹万零壹拾 源码: function toChineseBig(num) {// 将接 ...

  5. 将数字转换成中文金额的大写形式

    package com.unteck.fms.web.businessdata.controller; import org.springframework.beans.factory.annotat ...

  6. java 数字转换成汉字_Java-String-阿拉伯数字转换成中文汉字数字

    package com.test; public class NumberUtils { private static final String[] UNITS = { "", & ...

  7. js将数字转换成中文大写

    //完成将 toChineseNum, 可以将数字转换成中文大写的表示,处理到万级别,例如 toChineseNum(12345),返回 一万二千三百四十五.const toChinesNum = ( ...

  8. C语言-如何将用户输入的金额数字转换成中文大写?

    实战: 如何将用户输入的金额数字转换成中文大写? #include <stdio.h>int main() {// 输入金额转换成大写int money; // 输入数字int money ...

  9. 将数字转换成中文大写的算法

    //名称:ConvertSignCap   //参数:number   //返回:CapNumber   //描述:将传入的单个数字转换成中文大写形式   //创建人:刘权 2004-11-16    ...

最新文章

  1. throws throw 自定义异常
  2. 调试JavaScript/VB Script脚本程序(IE篇)
  3. 给计算机图片文件夹加密码,电脑文件夹设置密码的方法是什么【图文】
  4. Hadoop Yarn配置参数整理(非常全面)
  5. WPF 带CheckBox、图标的TreeView
  6. Homography 知多少?
  7. python一条线分段显示颜色_Python诅咒显示分段fau
  8. MySQL (一)(未完成)
  9. Android开发文摘集合1
  10. excel第一次打开报错 向程序发送命令时出错 多种解决办法含终极解决方法
  11. 一键提取app源码_【补发】自动答题脚本教程及源码分享(无视分辨率)
  12. Dell插入耳机仍然外放的问题解决
  13. matlab画图,仅显示部分图例
  14. 如何优雅的注入Java Agent内存马
  15. WiMAX与Wi-Fi、DSL和3G的竞合关系
  16. Resolution-robust Large Mask Inpainting with Fourier Convolutions 解读
  17. 节假日api接口之获取指定日期的节假日信息
  18. SPSS Modeler 多元线性回归分析(指南 第九章)
  19. 子苗教育:抖音游戏推广怎么没有链接?
  20. maven 程序包不存在 https://repo.maven.apache.org/maven2 was cac hed in the local repository

热门文章

  1. C#中TimeSpan只保留整数时间
  2. Inanimate subject
  3. 【Vue】Vue的过渡动画
  4. vue 绑定动态class变量
  5. bfs写法 nightmare
  6. Artifactory搭建本地仓库
  7. 无序列表li去掉标志,文本不根据标记对齐
  8. 谁说大教堂就真落伍了?
  9. 阿里云龙珠训练营学习打卡第一天
  10. 使用dockerhub的jupyterhub搭建jupyterhub服务器