private Function hhhh(i As Range)
If i.Value >= 1 Then
If Int(i) = i Or Round(i, 2) = Int(i) Then
hhhh = Application.WorksheetFunction.Text(Int(i), "[dbnum2]") & "元整"
ElseIf Int(i * 10) = i * 10 Or Int(i) * 10 = Round(i, 2) * 10 Then
hhhh = Application.WorksheetFunction.Text(Int(i), "[dbnum2]") & "元" & Application.WorksheetFunction.Text(Right(Round(i, 2), 1), "[dbnum2]") & "角整"
Else
hhhh = Application.WorksheetFunction.Text(Int(i), "[dbnum2]") & "元" & Application.WorksheetFunction.Text(Left(Right(Round(i, 2), 2), 1), "[dbnum2]") & "角" & Application.WorksheetFunction.Text(Right(Round(i, 2), 1), "[dbnum2]") & "分"
End If
ElseIf i.Value < 1 And i.Value > 0 Then
If Int(i * 10) = i * 10 Then
hhhh = Application.WorksheetFunction.Text(Right(i, 1), "[dbnum2]") & "角"
Else
hhhh = Application.WorksheetFunction.Text(Left(Right(i, 2), 1), "[dbnum2]") & "角" & Application.WorksheetFunction.Text(Right(i, 1), "[dbnum2]") & "分"
End If
ElseIf i = o Then hhhh = Application.WorksheetFunction.Text(Int(i), "[dbnum2]") & "元"
Else
If Int(i) = i Then
hhhh = "负" & Application.WorksheetFunction.Text(Int(Abs(i)), "[dbnum2]") & "元"
ElseIf Int(i * 10) = i * 10 Or Round(Abs(i), 2) * 10 = Int(Abs(i)) * 10 Then
hhhh = "负" & Application.WorksheetFunction.Text(Int(Abs(i)), "[dbnum2]") & "元" & Application.WorksheetFunction.Text(Right(i, 1), "[dbnum2]") & "角"
Else
hhhh = "负" & Application.WorksheetFunction.Text(Int(Abs(i)), "[dbnum2]") & "元" & Application.WorksheetFunction.Text(Left(Right(Round(i, 2), 2), 1), "[dbnum2]") & "分" & Application.WorksheetFunction.Text(Right(Round(i, 2), 1), "[dbnum2]") & "分"
End If
End If
End Function
本文来源:https://www.2haoxitong.net/k/doc/0f7885ac2af90242a895e5fd.html
文档为doc格式