Excel用VBA转换数字大写
发布网友
发布时间:2022-05-08 08:27
我来回答
共4个回答
热心网友
时间:2024-01-21 09:18
首先,第一步要,选择要设置格式的数据区域,
第二步,右击在快捷菜单中选择“设置单元格格式”,
第三步,在弹出的对话框中选择“数字”选项卡,在列表中选择“特殊”,
第四步,再在右边的列表中选择“中文大写数字”,最后点击确定。
热心网友
时间:2024-01-21 09:18
Function DX(M)'185个字符
DX = IIf(Abs(M) < 0.005, a, Replace(Replace(Replace(Join(Application.Text(Split(Format(M, " 0. 0 0")), Split(" [DBnum2] [DBnum2]圆0角;;圆零 [DBnum2]0分;;整")), a), "零圆零", a), "零圆", a), "零整", "整"))
End Function
热心网友
时间:2024-01-21 09:19
Public Function UpperCaseRMB(myCell As Range) As String
On Error GoTo errLine
Dim tmpCell As Range
Dim strAddress As String
strAddress = myCell.Address(True, True, xlR1C1)
Set tmpCell = myCell.Offset(0, Columns.Count - myCell.Column)
tmpCell.FormulaR1C1 = "=IF(" & strAddress & "=0,"""",IF(ABS(" & strAddress & ")<0.995,"""",TEXT(INT(ROUND(ABS(" & strAddress & "),2)),""[DBNum2]"")&""元"")&IF(RIGHT(TEXT(" & strAddress & ","".00""),2)*1=0,IF(ABS(" & strAddress & ")<0.005,"""",""整""), TEXT(IF(ABS(" & strAddress & ")<0.095,"""",LEFT(RIGHT(TEXT(" & strAddress & ","".00""),2))),""[dbnum2]"")&IF(LEFT(RIGHT(TEXT(" & strAddress & ","".00""),2))*1=0,"""",""角"")&IF(RIGHT(TEXT(" & strAddress & ","".00""))*1=0,""整"",TEXT(RIGHT(TEXT(" & strAddress & ","".00"")),""[dbnum2]"")&""分"")))"
UpperCaseRMB = tmpCell.Value
tmpCell.ClearContents
Set tmpCell = Nothing
exitLine:
Exit Function
errLine:
UpperCaseRMB = ""
Resume exitLine
End Function
热心网友
时间:2024-01-21 09:19
Function RMB(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追问这个我测试的时候没通过..