首页  编辑  

Excel中转换金额中文大写

Tags: /计算机文档/Office/   Date Created:
Excel中的转换金额中文大小写的函数
Function UpperCurrency(Value) As String
 ' Write By Kingron ,2003.08.12
 ' 转换小写金额为大写
 
 On Error Resume Next
   
 ybb = Round(Value * 100) '将输入的数值扩大100倍,进行四舍五入
 y = Int(ybb / 100) '截取出整数部分
 j = Int(ybb / 10) - y * 10 '截取出十分位
 f = ybb - y * 100 - j * 10 '截取出百分位
 zy = Application.WorksheetFunction.Text(y, "[dbnum2]") '将整数部分转为中文大写
 zj = Application.WorksheetFunction.Text(j, "[dbnum2]") '将十分位转为中文大写
 zf = Application.WorksheetFunction.Text(f, "[dbnum2]") '将百分位转为中文大写
 UpperCurrency = zy & "圆"
 If f <> 0 And j <> 0 Then
    UpperCurrency = UpperCurrency & zj & "角" & zf & "分"
    If y = 0 Then
      UpperCurrency = zj & "角" & zf & "分"
    End If
 End If
 If f = 0 And j <> 0 Then
   UpperCurrency = UpperCurrency & zj & "角"
   If y = 0 Then
     UpperCurrency = zj & "角"
   End If
 End If
 If f <> 0 And j = 0 Then
   UpperCurrency = UpperCurrency & zj & zf & "分"
   If y = 0 Then
      UpperCurrency = zf & "分"
   End If
 End If
 If (Value = "") Or (UpperCurrency = "零圆") Then UpperCurrency = ""   '如没有输入任何数值为0
End Function