Eccel中用宏完成人民幣小寫(xiě)轉(zhuǎn)換大寫(xiě)
1.打開(kāi)Excel,按Alt+F11(或者選擇菜單工具→宏→Visual Basic 編輯器),進(jìn)入后新建模塊(插入→模塊),鍵入以下語(yǔ)句:
Function NCN(account) 'Nummary Capital Number
ybb = Round(account * 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]")
NCN = zy & "元"
If j = 0 And f = 0 Then
NCN = NCN & "整"
End If
If f <> 0 And j <> 0 Then
NCN = NCN & zj & "角" & zf & "分"
If y = 0 Then
NCN = zj & "角" & zf & "分"
End If
End If
If f = 0 And j <> 0 Then
NCN = NCN & zj & "角"
If y = 0 Then
NCN = zj & "角"
End If
End If
If f <> 0 And j = 0 Then
NCN = NCN & zj & zf & "分"
If y = 0 Then
NCN = zf & "分"
End If
End If
If account = "" Then
NCN = ""
End If
End Function
聯(lián)系客服