1 / 2
文档名称:

在excel表格中人民币小写金额自动转大写金额的方法.doc

格式:doc   大小:199KB   页数:2
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

在excel表格中人民币小写金额自动转大写金额的方法.doc

上传人:mh900965 2018/2/23 文件大小:199 KB

下载得到文件列表

在excel表格中人民币小写金额自动转大写金额的方法.doc

相关文档

文档介绍

文档介绍:在excel表格中人民币小写金额自动转大写金额的方法
通过一个自定义函数就可以实现!
下面就通过此例来介绍使用自定义函数的全过程,即使是初学Excel的朋友,也会感觉其操作实际上是非常简单的。
1. 选择菜单“工具→宏→Visual Basic编辑器”命令,打开Visual Basic窗口,我们将在这里自定义函数。
2. 进入Visual Basic窗口后,选择菜单“插入→模块”命令,于是得到“模块1”,在其中输入如下自定义函数的代码:
public function zdx(x as currency) as string
dim lnp as integer
dim prc as string
dim tmp as string
dim nob as currency
dim dx as string
dim xx as string
dim zhen as boolean
dim str(10) as string
dim china as string
china = "分角元拾佰仟万拾佰仟亿"
str(0) = "零"
str(1) = "壹"
str(2) = "贰"
str(3) = "叁"
str(4) = "肆"
str(5) = "伍"
str(6) = "陆"
str(7) = "柒"
str(8) = "捌"
str(9) = "玖"
zhen = true
x = formatnumber(x, 2)
prc = cstr(x)
prc = replace(prc, ",", "")
lnp = len(prc)
for i = lnp - 1 to 1 step -1
if mid(prc, i, 1) = "." then
select case lnp - i
case 1
prc = replace(prc, ".", "") + "0"
case 2
prc = replace(prc, ".", "")
end select
zhen = false
exit for
end if
next i
if zhen then prc = prc + "00"
lnp = len(prc)
for i = 1 to lnp
tmp = str(mid(prc, i, 1)) & tmp
next i
zdx = ""
fy = 1
for i = 1 to lnp
xx = mid(tmp, i, 1)
dx = mid(china, i, 1)
if xx <> "零" then
zdx = xx & dx & zdx
f = 1
else
if i = 3 then
zdx = dx & zdx
end if
if i = 7 then
zdx = dx & zdx
end if
if f then
zdx = "零" & zdx
end if
f = 0
end if
next i
if zhen then zdx = zdx + "整"
zdx