1 / 3
文档名称:

EXCEL表格中将数字金额转换为英文.doc

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

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

分享

预览

EXCEL表格中将数字金额转换为英文.doc

上传人:changjinlai 2020/5/29 文件大小:20 KB

下载得到文件列表

EXCEL表格中将数字金额转换为英文.doc

文档介绍

文档介绍:Excel表格中如何将数字金额转换为英文(如B1列写162890元,YDOLLARSANDNOCENTS)1、新建Excel表格2、按住“Alt+F11”打开VBA编辑器3、在VBA编辑器中单击菜单栏“插入”——模块4、在打开的模块中输入如下代码:OptionExplicitFunction数字转英文(ByValMyNumber)DimDollars,Cents,TempDimDecimalPlace,CountReDimPlace(9)AsStringPlace(2)="Thousand"Place(3)="Million"Place(4)="Billion"Place(5)="Trillion"MyNumber=Trim(Str(MyNumber))DecimalPlace=InStr(MyNumber,".")IfDecimalPlace>0ThenCents=GetTens(Left(Mid(MyNumber,DecimalPlace+1)&_"00",2))MyNumber=Trim(Left(MyNumber,DecimalPlace-1))EndIfCount=1DoWhileMyNumber<>""Temp=GetHundreds(Right(MyNumber,3))IfTemp<>""ThenDollars=Temp&Place(Count)&DollarsIfLen(MyNumber)>3ThenMyNumber=Left(MyNumber,Len(MyNumber)-3)ElseMyNumber=""EndIfCount=Count+1LoopSelectCaseDollarsCase""Dollars="NoDollars"Case"One"Dollars="OneDollar"CaseElseDollars=Dollars&"Dollars"EndSelectSelectCaseCentsCase""Cents="andNoCents"Case"One"Cents="andOneCent"CaseElseCents="and"&Cents&"Cents"EndSelect数字转英文=Dollars&CentsEndFunctionFunctionGetHundreds(ByValMyNumber)DimResultAsStringIfVal(MyNumber)=0ThenExitFunctionMyNumber=Right("000"&MyNumber,3)IfMid(MyNumber,1,1)<>"0"ThenResult=GetDigit(Mid(MyNumber,1,1))&"Hundred"EndIfIfMid(MyNumber,2,1)<>"0"ThenResult=Result&GetTens(Mid(MyNumber,2))ElseResult=Result&GetDigit(Mid(MyNumber,3))EndIfGetHundreds=ResultEndFunctionFunctionGetTens(TensText)DimResultAsStringResult=""IfVal(Left(TensText,1))=1ThenSelectCaseVal(TensText)Case10:Result="Te