Excel數(shù)字大寫轉(zhuǎn)換_第1頁
Excel數(shù)字大寫轉(zhuǎn)換_第2頁
Excel數(shù)字大寫轉(zhuǎn)換_第3頁
Excel數(shù)字大寫轉(zhuǎn)換_第4頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、1.阿拉伯?dāng)?shù)字轉(zhuǎn)換中文大寫。=IF(A7-INT(A7)=0,TEXT(A7,"DBNUM2")&"元整",IF(INT(A7*10)-A7*10=0,TEXT(INT(A7),"DBNUM2")&"元"&TEXT(INT(A7*10)-INT(A7)*10),"DBNUM2")&"角整",TEXT(INT(A7),"DBNUM2")&"元"&IF(INT(A7*10)-INT(A7)*1

2、0=0,"零",TEXT(INT(A7*10)-INT(A7)*10,"DBNUM2")&"角")&TEXT(RIGHT(A7,1),"DBNUM2")&"分")該函數(shù)中只需將A7換成你要轉(zhuǎn)換的數(shù)值所在單元格即可。2.阿拉伯?dāng)?shù)字轉(zhuǎn)換英文大寫(編寫SpellNumber實(shí)例函數(shù))2.1 啟動 Microsoft Excel。 2.2 按 Alt+F11 啟動 Visual Basic 編輯器。 2.3 在“插入”菜單上,單擊“模塊”。 2.4 在模塊表中鍵入下面的代碼。Fu

3、nction ConvertCurrencyToEnglish(ByVal MyNumber)          Dim Temp          Dim Dollars, Cents          Dim DecimalPlace, Count      

4、60;   ReDim Place(9) As String          Place(2) = " Thousand "          Place(3) = " Million "          Place(4) = " Billion &quo

5、t;          Place(5) = " Trillion "          ' Convert MyNumber to a string, trimming extra spaces.          MyNumber = Trim(Str(Round(MyNumber, 2)

6、0;         ' Find decimal place.          DecimalPlace = InStr(MyNumber, ".")          ' If we find decimal place.      &#

7、160;   If DecimalPlace > 0 Then             ' Convert cents             Temp = Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2)    

8、;         Cents = ConvertTens(Temp)             ' Strip off cents from remainder to convert.             MyNumber = Trim(Left(MyNumber,

9、DecimalPlace - 1)          End If          Count = 1          Do While MyNumber <> ""          

10、0;  ' Convert last 3 digits of MyNumber to English dollars.             Temp = ConvertHundreds(Right(MyNumber, 3)             If Temp <> "" Then Dollars =

11、Temp & Place(Count) & Dollars             If Len(MyNumber) > 3 Then                ' Remove last 3 converted digits from MyNumber.   &#

12、160;            MyNumber = Left(MyNumber, Len(MyNumber) - 3)             Else                MyNumber = "

13、"             End If             Count = Count + 1          Loop          ' Clean

14、 up dollars.          Select Case Dollars             Case ""                Dollars = "No Dollars"&

15、#160;            Case "One"                Dollars = "One Dollar"             Case Else

16、60;               Dollars = Dollars & " Dollars"          End Select          ' Clean up cents.    

17、60;     Select Case Cents             Case ""                Cents = " Only"        &

18、#160;    Case "One"                Cents = " And One Cent"             Case Else        &#

19、160;       Cents = " And " & Cents & " Cents"          End Select          ConvertCurrencyToEnglish = Dollars & Cents     &

20、#160; End Function      Private Function ConvertHundreds(ByVal MyNumber)          Dim Result As String          ' Exit if there is nothing to convert.     &

21、#160;    If Val(MyNumber) = 0 Then Exit Function          ' Append leading zeros to number.          MyNumber = Right("000" & MyNumber, 3)      

22、60;   ' Do we have a hundreds place digit to convert?          If Left(MyNumber, 1) <> "0" Then             If Right("000" & MyNumber, 2) <> 0 Th

23、en             Result = ConvertDigit(Left(MyNumber, 1) & " Hundred and "             Else             Resu

24、lt = ConvertDigit(Left(MyNumber, 1) & " Hundred "             End If         End If          ' Do we have a tens place digit to convert?&

25、#160;         If Mid(MyNumber, 2, 1) <> "0" Then             Result = Result & ConvertTens(Mid(MyNumber, 2)          Else  &#

26、160;          ' If not, then convert the ones place digit.             Result = Result & ConvertDigit(Mid(MyNumber, 3)          End If &#

27、160;        ConvertHundreds = Trim(Result)       End Function       Private Function ConvertTens(ByVal MyTens)          Dim Result As String   &#

28、160;      ' Is value between 10 and 19?          If Val(Left(MyTens, 1) = 1 Then             Select Case Val(MyTens)        &#

29、160;       Case 10: Result = "Ten"                Case 11: Result = "Eleven"                Case 12:

30、 Result = "Twelve"                Case 13: Result = "Thirteen"                Case 14: Result = "Fourteen"  &#

31、160;             Case 15: Result = "Fifteen"                Case 16: Result = "Sixteen"         

32、0;      Case 17: Result = "Seventeen"                Case 18: Result = "Eighteen"                Case 19:

33、 Result = "Nineteen"                Case Else             End Select          Else    

34、0;        ' . otherwise it's between 20 and 99.             Select Case Val(Left(MyTens, 1)                Case 2: Result

35、= "Twenty"                Case 3: Result = "Thirty"                Case 4: Result = "Forty"     

36、;           Case 5: Result = "Fifty"                Case 6: Result = "Sixty"             &

37、#160;  Case 7: Result = "Seventy"                Case 8: Result = "Eighty"                Case 9: Result = "Ninety"

38、                Case Else             End Select             ' Convert ones place digit.  &

39、#160;          If Val(Right(MyTens, 1) = 0 Then             Result = Result & " " & ConvertDigit(Right(MyTens, 1)          

40、0;  Else             Result = Result & "-" & ConvertDigit(Right(MyTens, 1)             End If         End If          ConvertTens = Result      End Function       Private Function ConvertDigit(ByVal MyDigit)          Select Case Val(MyDigit)    

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論