excell中如何將小寫金額轉換成英文大寫

時間 2021-08-13 22:53:50

1樓:匿名使用者

這個比較複雜,在excel中沒有現成的選項,需要自己建立一個函式才能達成,以下為建立過程,希望對你有用:

1.建立一個模組:

在sheet上,右鍵-》檢視**。選中「模組」-》插入模組。

2.寫**:

option explicit

dim strno(19) as string

dim unit(8) as string

dim strtens(9) as string

public function numbertostring(number as double) as string

dim str as string, beforepoint as string, afterpoint as string, tmpstr as string

dim point as integer

dim nbit as integer

dim curstring as string

dim nnumlen as integer

dim t as string

call init

str = cstr(round(number, 2))

' str = number

if instr(1, str, ".") = 0 then

beforepoint = str

afterpoint = ""

else

beforepoint = left(str, instr(1, str, ".") - 1)

t = right(str, len(str) - instr(1, str, "."))

if len(t) < 2 then afterpoint = val(t) * 10

if len(t) = 2 then afterpoint = val(t)

if len(t) > 2 then afterpoint = val(left(t, 2))

end if

if len(beforepoint) > 12 then

numbertostring = "too big."

exit function

end if

str = ""

do while len(beforepoint) > 0

nnumlen = len(beforepoint)

if nnumlen mod 3 = 0 then

curstring = left(beforepoint, 3)

beforepoint = right(beforepoint, nnumlen - 3)

else

curstring = left(beforepoint, (nnumlen mod 3))

beforepoint = right(beforepoint, nnumlen - (nnumlen mod 3))

end if

nbit = len(beforepoint) / 3

tmpstr = decodehundred(curstring)

if (beforepoint = string(len(beforepoint), "0") or nbit = 0) and len(curstring) = 3 then

if cint(left(curstring, 1)) <> 0 and cint(right(curstring, 2)) <> 0 then

'tmpstr = left(tmpstr, instr(1, tmpstr, unit(4)) + len(unit(4))) & unit(8) & " " & right(tmpstr, len(tmpstr) - (instr(1, tmpstr, unit(4)) + len(unit(4))))

else 'if cint(left(curstring, 1)) <> 0 and cint(right(curstring, 2)) = 0 then

'tmpstr = unit(8) & " " & tmpstr

end if

end if

if nbit = 0 then

str = trim(str & " " & tmpstr)

else

str = trim(str & " " & tmpstr & " " & unit(nbit))

end if

if left(str, 3) = unit(8) then str = trim(right(str, len(str) - 3))

if beforepoint = string(len(beforepoint), "0") then exit do

'debug.print str

loop

beforepoint = str

if len(afterpoint) > 0 then

afterpoint = unit(8) & " " & unit(7) & " " & decodehundred(afterpoint) & " " & unit(5)

else

afterpoint = unit(5)

end if

numbertostring = beforepoint & " " & afterpoint

end function

private function decodehundred(hundredstring as string) as string

dim tmp as integer

if len(hundredstring) > 0 and len(hundredstring) <= 3 then

select case len(hundredstring)

case 1

tmp = cint(hundredstring)

if tmp <> 0 then decodehundred = strno(tmp)

case 2

tmp = cint(hundredstring)

if tmp <> 0 then

if (tmp < 20) then

decodehundred = strno(tmp)

else

if cint(right(hundredstring, 1)) = 0 then

decodehundred = strtens(int(tmp / 10))

else

decodehundred = strtens(int(tmp / 10)) & "-" & strno(cint(right(hundredstring, 1)))

end if

end if

end if

case 3

if cint(left(hundredstring, 1)) <> 0 then

decodehundred = strno(cint(left(hundredstring, 1))) & " " & unit(4) & " " & decodehundred(right(hundredstring, 2))

else

decodehundred = decodehundred(right(hundredstring, 2))

end if

case else

end select

end if

end function

private sub init()

if strno(1) <> "one" then

strno(1) = "one"

strno(2) = "two"

strno(3) = "three"

strno(4) = "four"

strno(5) = "five"

strno(6) = "six"

strno(7) = "seven"

strno(8) = "eight"

strno(9) = "nine"

strno(10) = "ten"

strno(11) = "eleven"

strno(12) = "twelve"

strno(13) = "thirteen"

strno(14) = "fourteen"

strno(15) = "fifteen"

strno(16) = "sixteen"

strno(17) = "seventeen"

strno(18) = "eighteen"

strno(19) = "nineteen"

strtens(1) = "ten"

strtens(2) = "twenty"

strtens(3) = "thirty"

strtens(4) = "forty"

strtens(5) = "fifty"

strtens(6) = "sixty"

strtens(7) = "seventy"

strtens(8) = "eighty"

strtens(9) = "ninety"

unit(1) = "thousand" '材熌

unit(2) = "million" '材熌

unit(3) = "billion" '材熌

unit(4) = "hundred"

unit(5) = "only"

unit(6) = "point"

unit(7) = "cents"

unit(8) = "and"

end if

end sub

儲存此**到本地

3.模組中已經定義了函式名稱:numbertostring

直接當作excel本地函式使用,例如在a1=7,在b1中輸入=numbertostring(a1)就可以了。

2樓:匿名使用者

a1單元格輸入資料,在b1單元格輸入下面公式即可:

對比起,原來是英文,我以為是漢語呢,以下是漢語的

=if(a1<0,"金額為負無效",

(if(or(a1=0,a1=""),"(人民幣)零元",

if(a1<1,"(人民幣)",

text(int(a1),"[dbnum2](人民幣)g/通用格式")&"元"))))&

if((int(a1*10)-int(a1)*10)=0,

if(int(a1*100)-int(a1*10)*10=0,"","零"),

(text(int(a1*10)-int(a1)*10,"[dbnum2]")&"角"))

&if(

(int(a1*100)-int(a1*10)*10)=0,

"整",

text((int(a1*100)-int(a1*10)*10),"[dbnum2]")&"分")

如何將小寫金額變成大寫數值,word中如何將小寫金額數字轉換為大寫

office學習技巧 word怎樣將小寫金額轉為大寫?word中如何將小寫金額數字轉換為大寫 設定方法 抄1 輸入所需要的阿拉伯數字,並選中 2 單擊插入 編號按鈕 3 彈出編號對話方塊,在編號型別列表中,選擇 壹,貳,叄 選項即可,如圖所示 4 單擊 確定 按鈕,即可實現將阿拉伯數字轉化為大寫金額...

如何將wps轉換為電子,如何將wps文件轉換為電子文件?

加菲帶你看電影 具體步驟為 1 啟動word,並開啟包含有需要轉換 的文件。2 將游標移至word 的任意單元格中,然後執行 選單的 選定 命令,選定整個 搜尋3 執行 編輯 選單的 複製 命令,將word 拷貝到剪貼簿中。4 啟動excel,然後開啟需要轉換的工作簿,並將游標移至所需的單元格中。5...

如何將紙質檔案轉化成電子,如何將紙質檔案轉化成電子文件

老羅自 如何將紙質文件,快速變成電子版的文字,分享4種實用的方法,提高工作效率 大耗子 買一臺掃描器 掃描一下就可以將紙質檔案轉化成電子文件了 用掃描器,可將紙質檔案轉換為txt pdf和 你是想要獲得純粹文字文件嗎?使用掃描器一般可以得到 格式的電子文件,但要想在原來的文件基礎上進行編輯,需要純粹...