首页 >专题 >excel >四步教你Excel将人民币数字金额转为中文大写

四步教你Excel将人民币数字金额转为中文大写

WBOY
WBOY转载
2022-06-24 11:56:367492浏览

本篇文章给大家带来了关于excel的相关知识,其中主要整理了将人民币数字金额转为中文大写的方法,下面一起来看一下,希望对大家有帮助。

四步教你Excel将人民币数字金额转为中文大写

相关学习推荐:excel教程

要将数字金额转为中文大写,需要经历以下几个步骤:

1.将阿拉伯小写数字转为中文大写。这可以用到前面章节例子中,将数字转为中文大写的代码,如:

Function RmbDx(ByVal c) As String<br>Application.Volatile True<br>c = Val(c)<br>RmbDx = Application.WorksheetFunction.Text(c, "[DBNum2]")<br>RmbDx = Replace(RmbDx, "-", "负")<br>End Function

2.在整数金额的后面添加“元整”.可以借助IF语句及FIX取整函数来判断某个金额是否整数金额。

Function RmbDx(ByVal c) As String<br>Application.Volatile True<br>c = Val(c)<br>RmbDx = Application.WorksheetFunction.Text(c, "[DBNum2]")<br>RmbDx = Replace(RmbDx, "-", "负")<br>If c = Fix(c) Then<br>RmbDx = RmbDx & "元整"<br>End If<br>End Function

3.在只包含“角”信息,不含“分”信息的金额中添加“元”和“分”信息.

Function RmbDx(ByVal c) As String<br>Application.Volatile True<br>Dim p As Integer<br>c = Val(c)<br>RmbDx = Application.WorksheetFunction.Text(c, "[DBNum2]")<br>RmbDx = Replace(RmbDx, "-", "负")<br>If c = Fix(c) Then<br>RmbDx = RmbDx & "元整"<br>Else<br>RmbDx = Replace(RmbDx, ".", "元")<br>If c * 10 = Fix(c * 10) Then<br>RmbDx = RmbDx & "角"<br>End If<br>End If<br>End Function

4.在包含“角”与“分”信息的数据中添加“角”和“分”信息。

Function RmbDx(ByVal c) As String<br>Application.Volatile True<br>Dim p As Integer<br>c = Val(c)<br>RmbDx = Application.WorksheetFunction.Text(c, "[DBNum2]")<br>RmbDx = Replace(RmbDx, "-", "负")<br>If c = Fix(c) Then<br>RmbDx = RmbDx & "元整"<br>Else<br>p = InStr(RmbDx, ".")<br>RmbDx = Replace(RmbDx, ".", "元")<br>If c * 10 = Fix(c * 10) Then<br>RmbDx = RmbDx & "角"<br>Else<br>RmbDx = Left(RmbDx, p) & Mid(RmbDx, p + 1, 1) & "角" & Right(RmbDx, 1) & "分"<br>End If<br>End If<br>End Function

这样即可得到将人民币金额转为中文大写金额的自定义函数RmbDx,效果如下图。

08.png

相关学习推荐:excel教程

以上是四步教你Excel将人民币数字金额转为中文大写的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:csdn.net。如有侵权,请联系admin@php.cn删除