求助金额自动大写问题
改个车商务车改装
2024-11-17 07:45:36
最佳回答
使用vba写了自定义函数,名为daxie,直接在单元格中输入函数名,其参数为一个单元格引用,然后即可得到转换结果。目前支持12种货币,最大金额位数支持到7位,即小数点左侧5位,小数点右侧两位,金额最大单位不能超过“万”。下面是附件下载、操作动画以及源代码:function daxie(rng as range) as string dim strcurr as string select case ucase(left(rng.value, 3)) case "cny": strcurr = "人民币" case "frf": strcurr = "法国法郎" case "hkd": strcurr = "港元" case "chf": strcurr = "瑞士法郎" case "usd": strcurr = "美元" case "cad": strcurr = "加拿大元" case "gbp": strcurr = "英镑" case "nlg": strcurr = "荷兰盾" case "dem": strcurr = "德国马克" case "bef": strcurr = "比利时法郎" case "jpy": strcurr = "日元" case "aud": strcurr = "澳大利亚元" end select dim strnum as string, str as string, result as string strnum = mid(rng.value, 4, len(rng.value)) dim i as integer for i = 1 to len(rng.value) - 3 str = mid(strnum, i, 1) select case val(str) case 1: str = "壹" case 2: str = "贰" case 3: str = "叁" case 4: str = "肆" case 5: str = "伍" case 6: str = "陆" case 7: str = "柒" case 8: str = "捌" case 9: str = "玖" case 0: str = "零" end select result = result & str next i dim danwei as variant dim getres as string danwei = array("万", "千", "百", "十", "元", "角", "分") select case len(rng.value) - 3 case 3 for i = 1 to 3 getres = getres & mid(result, i, 1) & danwei(i + 3) next i case 4 for i = 1 to 4 getres = getres & mid(result, i, 1) & danwei(i + 2) next i case 5 for i = 1 to 5 getres = getres & mid(result, i, 1) & danwei(i + 1) next i case 6 for i = 1 to 6 getres = getres & mid(result, i, 1) & danwei(i) next i case 7 for i = 1 to 7 getres = getres & mid(result, i, 1) & danwei(i - 1) next i end select daxie = strcurr & getresend function 20210311