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

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

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]")&"分")

在excel表中,如何將數字小寫自動轉換成中文大寫

可選用以下方法 1 如果都是整數,可通過單元格格式設定實現。選定單元格,在其上點滑鼠右鍵 設定單元格格式 點 數字 標籤 特殊 在 型別 中選擇 中文大寫數字 2 如果存在小數,可用以下公式處理 if isnumber a1 if int a1 text int a1 dbnum2 元角 if in...

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

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

如何將檔案轉化為X檔案,如何將DOC檔案轉化為DOCX檔案

1 首先,新建乙個word文件 2 預設的文件字尾名為docx 3 雙擊開啟後,選擇檔案選單 4 在彈出的選單視窗中選擇 另存為 5 選擇另儲存的目 6 下拉儲存的型別 7 找到doc型別,選中 8 然後,儲存,可以看到doc型別的檔案了 邴格忻映 用乙個office外掛程式可以開啟docx檔案,開...