Excel将价钱小写转换大写

1、打开一个Excel工作表

2、按ALT+F11

3、新建一个模块

4、粘贴以下代码:

Public Function Daxie(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]") & "分")
    Daxie = IIf(Abs(M) < 0.005, "", IIf(M < 0, "负" & A & B & C, A & B & C))
End Function
5、在单元格中输入 =daxie(A1) 即可调用

添加评论

Loading