怎样让Excel中数字自动为人民币大写?
发布网友
发布时间:2022-04-24 14:12
我来回答
共4个回答
热心网友
时间:2022-05-21 12:29
第一种方法:通过函数嵌套实现
数字转人民币大写形式的公式是:
=IF(B1<0,"金额为负无效",
(IF(OR(B1=0,B1=""),"(人民币)零元",
IF(B1<1,"(人民币)",
TEXT(INT(B1),"[dbnum2](人民币)G/通用格式")&"元"))))&
IF(
(INT(B1*10)-INT(B1)*10)=0,
IF(INT(B1*100)-INT(B1*10)*10=0,"","零"),
(TEXT(INT(B1*10)-INT(B1)*10,"[dbnum2]")&"角"))
&IF(
(INT(B1*100)-INT(B1*10)*10)=0,
"整",
TEXT((INT(B1*100)-INT(B1*10)*10),"[dbnum2]")&"分")
数字转人民币大写形式的公式是:
="大写金额:"&IF(TRIM(B1)="","",IF(B1=0,"","人民币"&IF(B1<0,"负",)&IF(INT(B1),TEXT(INT(ABS(B1)),"[dbnum2]")&"元",)&IF(INT(ABS(B1)*10)-INT(ABS(B1))*10,TEXT(INT(ABS(B1)*10)-INT(ABS(B1))*10,"[dbnum2]")&"角",IF(INT(ABS(B1))=ABS(B1),,IF(ABS(B1)<0.1,,"零")))&IF(ROUND(ABS(B1)*100-INT(ABS(B1)*10)*10,),TEXT(ROUND(ABS(B1)*100-INT(ABS(B1)*10)*10,),"[dbnum2]")&"分","整")))
2
第二种方法:通过宏VBA自定义函数实现第一步:按下ALT+F11组合键,或者是单击工具——宏——Visual Basic编辑器,进入Visual Basic编程环境,单击“插入” 菜单——模块,复制下面代码,保存,退出关闭。Function N2RMB(M)
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]") & "分")
N2RMB = IIf(Abs(M) < 0.005, "", IIf(M < 0, "负" & A & b & c, A & b & c))
End Function
第二步:返回excel操作界面,在B1单元格输入:= N2RMB (A1),就可以将A1单元格的数字转为人民币大写,然后向下复制公式即可将全部的数字转为人民币大写。
热心网友
时间:2022-05-21 13:47
选择单元格右键,设置单元格格式,如图:
看错了大写公式=IF(ISNUMBER(A4),IF(INT(A4),TEXT(INT(A4),"[dbnum2]")&"
元
",)&IF(INT(A4*10)-INT(A4)*10,TEXT(INT(A4*10)-INT(A4)*10,"[dbnum2]")&"
角
",IF(INT(A4)=A4,,IF(A4<0.1,,"
零
")))&IF(ROUND((A4)*100-INT(A4*10)*10,),TEXT(ROUND(A4*100-INT(A4*10)*10,),"[dbnum2]")&"
分
","
整
"),"")
热心网友
时间:2022-05-21 15:21
=IF((J27-INT(J27))=0,TEXT(J27,"[DBNUM2]")&"元整",IF(INT(J27*10)-J27*10=0,TEXT(INT(J27),"[DBNUM2]")&"元"&TEXT(INT(J27*10)-INT(J27)*10,"[DBNUM2]")&"角整",TEXT(INT(J27),"[DBNUM2]")&"元"&IF(INT(J27*10)-INT(J27*10),"零",TEXT(INT(J27*10)-INT(J27)*10,"[DBNUM2]")&"角")&TEXT(RIGHT(J27,1),"[DBNUM2]")&"分"))
把j27改成你的单元格
热心网友
时间:2022-05-21 17:13
设置单元格格式,把数字格式设置为你想要的格式即可。