1、今天跟大家介绍一下如何捂执涡扔使用VBA将数字转为大写人民币,如下图Excel表我们想要将合计数字转为人民币大写。
2、同时按下Alt+F11打开VBA编辑页面,然后点击sheet1
3、录入VBA代码
4、插入一个矩形,然后选中矩形右击鼠标,接着点击指定宏
5、点击sheet1数字转人民币大写金额,然后点击【确定】
6、选择想要转为人民币大写的单元格,然后点击插入的矩形就可以将数字转为矩形了
7、很多朋友都在好奇VBA代码是什么下面就跟大家分享一下,另外如果需要VBA定制,可以百度方方格子Sub 数字转人民币大写金庞诌桃趋额() On Error Resume Next dim M as Range set M = ActiveCell y = Int(Round(100 * Abs(M)) / 100) j = Round(100 * Abs(M) + 0.00001) - y * 100 f = (j / 10 - Int(j / 10)) * 10 A = IIf(y < 1, "", Application.Text(y, "[DBNum2]") & "元") b = IIf(j > 9.5, Application.Text(Int(j / 10), "[DBNum2]") & "角", IIf(y < 1, "", IIf(f > 1, "零", ""))) c = IIf(f < 1, "整", Application.Text(Round(f, 0), "[DBNum2]") & "分") M = IIf(Abs(M) < 0.005, "", IIf(M < 0, "负" & A & b & c, A & b & c))End Sub