数字大小写转换
的有关信息介绍如下:在与报销单类似的财务单据填写过程中,我们除了要输入用阿拉伯数字表示的小写数字金额外,还要输入相应的中文大写数字。如果手工进行处理,不但输入时很繁琐,而且还很容易出散漏错,经常会造成大小写不相符慎桐的情况发生。为此,我们可以利用VBA自定义一个函数,然后再利用这个自定义的函数来实现货币大小的自动转换。这样,不但方便快捷,而且不易出错。具体的操作步骤如下: 1. 启动Excel。按“Alt+F11”快捷键打开“Visual Basic编辑器”。2. 在“Visual Basic编辑器”中,单击“插入”菜单栏中的“模块”命令,插入一个模块。双击左侧“工程”窗口中的“模块1”选项,在窗口右边展开“模块1(代码)”编辑窗口,然后输入如下代码:Function dx(q)Dim Cur as Long,yuan as LongDim Jiao as Integer,Fen as IntegerDim CnYuan as String, CnJiao as String, CnFen as StringIf q = "" Thendx = 0Exit FunctionEnd IfCur = Round(q * 100)Yuan = Int(Cur / 100)Jiao = Int(Cur / 10) - Yuan * 10Fen = Cur - Yuan * 100 - Jiao * 10CnYuan = Application.WorksheetFunction.Text(Yuan, "[DBNum2]")CnJiao = Application.WorksheetFunction.Text(Jiao, "[DBNum2]")CnFen = Application.WorksheetFunction.Text(Fen, "[DBNum2]")dx = CnYuan & "元" & "整"d1 = CnYuan & "元"If Fen <> 0 And Jiao <> 0 Thendx = d1 & CnJiao & "角" & CnFen & "分"If Yuan = 0 Thendx = CnJiao & "角" & CnFen & "分"End IfEnd IfIf Fen = 0 And Jiao <> 0 Thendx = d1 & CnJiao & "角" & "整"If Yuan = 0 Thendx = CnJiao & "角" & "整"End IfEnd IfIf Fen <> 0 And Jiao = 0 Thendx = d1 & CnJiao & CnFen & "分"If Yuan = 0 Thendx = CnFen & "分"End IfEnd IfEnd Function输入完成后,关闭“Visual Basic编辑器”返回工作表。现在,我们可测试一下这个函数。首先,在宽掘坦A1单元格中输入一个小写数字的金额,例如123456.78,然后,在A2单元格中输入公式:=dx(A1),确认后即可将A1所表示的小写数字金额转换为大写的数字金额,并在A2单元格中显示出来。怎么样,方便吧?