|
楼主 |
发表于 2019-12-21 01:26
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
4、会计专用数据处理模式,如20万元,57.05亿元,和数字大写功能
- '选项为w,w1,w2,y,y1,y2,d
- Function Jine(M, Optional jian As String = "") '200个字符
- If jian = "W" Or jian = "w" Then
- Jine = Format(Round(M * 0.0001, 0), "#,##0") & "万元"
- ElseIf jian = "Y" Or jian = "y" Then
- Jine = Format(Round(M * 0.00000001, 0), "#,##0") & "亿元"
- ElseIf jian = "W1" Or jian = "w1" Then
- Jine = Format(Round(M * 0.0001, 1), "#,##0.0") & "万元"
- ElseIf jian = "Y1" Or jian = "y1" Then
- Jine = Format(Round(M * 0.00000001, 1), "#,##0.0") & "亿元"
- ElseIf jian = "W2" Or jian = "w2" Then
- Jine = Format(Round(M * 0.0001, 2), "#,##0.00") & "万元"
- ElseIf jian = "Y2" Or jian = "y2" Then
- Jine = Format(Round(M * 0.00000001, 2), "#,##0.00") & "亿元"
- ElseIf jian = "D" Or jian = "d" Then
- Jine = "人民币" & (IIf(Abs(M) < 0.005, "", Replace(Replace(Replace(Join(Application.Text(Split(Format(M, " 0. 00")), Split("@ [DBNum2];;0 [>9][dbnum2]圆0角0分;[=0]圆整;[dbnum2]圆零0分")), ""), "零分", "整"), "0圆零", ""), "0圆", "")))
- Else
- Jine = IIf(Abs(M) < 0.005, "", Replace(Replace(Replace(Join(Application.Text(Split(Format(M, " 0. 00")), Split("@ [DBNum2];;0 [>9][dbnum2]圆0角0分;[=0]圆整;[dbnum2]圆零0分")), ""), "零分", "整"), "0圆零", ""), "0圆", ""))
- End If
- End Function
复制代码 5、会计专用公式余额公式,第四个参Total数表示可以忽略本期借贷方累计金额
- Function YUE(YUE0 As Range, JF As Range, DF As Range, Optional Total As String = 0) As Double
- Dim Var0, Var1, Var2
- Var0 = Val(YUE0.Value)
- Var1 = Val(JF.Value)
- Var2 = Val(DF.Value)
- If Total = 0 Then
- If IsNumeric(Var0) Then
- YUE = Round(Var0 + Var1 - Var2, 2)
- Else
- YUE = Round(Var1 - Var2, 2)
- End If
- Else
- If IsNumeric(Var0) Then
- If IsNumeric(Var1) And IsNumeric(Var2) And Var1 <> 0 And Var2 <> 0 Then
- YUE = Round(Var0, 2)
- Else
- YUE = Round(Var0 + Var1 - Var2, 2)
- End If
- Else
- YUE = Round(Var1 - Var2, 2)
- End If
- End If
- End Function
复制代码 6、身份证信息函数
- '第一个参数,目标单元格!
- '第二个参数选项:出生日期:csrq,出生年月日:csnyr,出生年月:csny,出生年:csn,年龄:nl,性别:xb,无参数,检查身份证长度是否有误!
- Function sfz(RNG As Range, Optional S As String = "csrq") As String
- If Len(RNG) <> 18 Then
- sfz = "SFZ长度错误"
- ElseIf (Mid(RNG, 11, 2) > 12) Or (Mid(RNG, 13, 2) > 31) Then
- sfz = "SFZ日期错误"
- ElseIf S = "csrq" Then
- sfz = Application.Text(Mid(RNG, 7, 8), "0000-00-00")
- ElseIf S = "csnyr" Then
- sfz = Application.Text(Mid(RNG, 7, 8), "0000年00月00日")
- ElseIf S = "csny" Then
- sfz = Application.Text(Mid(RNG, 7, 6), "0000年00月")
- ElseIf S = "csn" Then
- sfz = Application.Text(Mid(RNG, 7, 4), "0000年")
- ElseIf S = "nl" Then
- sfz = Year(Now()) - (19 & Mid(RNG, Len(RNG) / 2, 2)) & "岁"
- ElseIf S = "xb" Then
- sfz = IIf(Mid(RNG, 17, 1) Mod 2, "男", "女")
- Else
- sfz = "参数错误"
- End If
- End Function
复制代码
|
|