Excel自動轉換數字大小寫具體的操作步驟如下:
1. 啟動excel。按“alt+f11”快捷鍵開啟“visual basic編輯器”。
2. 在“visual basic編輯器”中,單擊“插入”選單欄中的“模組”命令,插入一個模組。雙擊左側“工程”視窗中的“模組1”選項,在視窗右邊展開“模組1(程式碼)”編輯視窗,然後輸入如下程式碼:
function dx(q)
dim cur as long,yuan as long
dim jiao as integer,fen as integer
dim cnyuan as string, cnjiao as string, cnfen as string
if q = "" then
dx = 0
exit function
end if
cur = round(q * 100)
yuan = int(cur / 100)
jiao = int(cur / 10) - yuan * 10
fen = cur - yuan * 100 - jiao * 10
cnyuan = application.worksheetfunction.text(yuan, "[dbnum2]")
cnjiao = application.worksheetfunction.text(jiao, "[dbnum2]")
cnfen = application.worksheetfunction.text(fen, "[dbnum2]")
dx = cnyuan & "元" & "整"
d1 = cnyuan & "元"
if fen <> 0 and jiao <> 0 then
dx = d1 & cnjiao & "角" & cnfen & "分"
if yuan = 0 then
dx = cnjiao & "角" & cnfen & "分"
if fen = 0 and jiao <> 0 then
dx = d1 & cnjiao & "角" & "整"
dx = cnjiao & "角" & "整"
if fen <> 0 and jiao = 0 then
dx = d1 & cnjiao & cnfen & "分"
dx = cnfen & "分"
end function
輸 入完成後,關閉“visual basic編輯器”返回工作表。現在,我們可測試一下這個函式。首先,在a1單元格中輸入一個小寫數字的金額,例如123456.78,然後,在a2單元 格中輸入公式:=dx(a1),確認後即可將a1所表示的小寫數字金額轉換為大寫的數字金額,並在a2單元格中顯示出來。怎麼樣,方便吧?
Excel自動轉換數字大小寫具體的操作步驟如下:
1. 啟動excel。按“alt+f11”快捷鍵開啟“visual basic編輯器”。
2. 在“visual basic編輯器”中,單擊“插入”選單欄中的“模組”命令,插入一個模組。雙擊左側“工程”視窗中的“模組1”選項,在視窗右邊展開“模組1(程式碼)”編輯視窗,然後輸入如下程式碼:
function dx(q)
dim cur as long,yuan as long
dim jiao as integer,fen as integer
dim cnyuan as string, cnjiao as string, cnfen as string
if q = "" then
dx = 0
exit function
end if
cur = round(q * 100)
yuan = int(cur / 100)
jiao = int(cur / 10) - yuan * 10
fen = cur - yuan * 100 - jiao * 10
cnyuan = application.worksheetfunction.text(yuan, "[dbnum2]")
cnjiao = application.worksheetfunction.text(jiao, "[dbnum2]")
cnfen = application.worksheetfunction.text(fen, "[dbnum2]")
dx = cnyuan & "元" & "整"
d1 = cnyuan & "元"
if fen <> 0 and jiao <> 0 then
dx = d1 & cnjiao & "角" & cnfen & "分"
if yuan = 0 then
dx = cnjiao & "角" & cnfen & "分"
end if
end if
if fen = 0 and jiao <> 0 then
dx = d1 & cnjiao & "角" & "整"
if yuan = 0 then
dx = cnjiao & "角" & "整"
end if
end if
if fen <> 0 and jiao = 0 then
dx = d1 & cnjiao & cnfen & "分"
if yuan = 0 then
dx = cnfen & "分"
end if
end if
end function
輸 入完成後,關閉“visual basic編輯器”返回工作表。現在,我們可測試一下這個函式。首先,在a1單元格中輸入一個小寫數字的金額,例如123456.78,然後,在a2單元 格中輸入公式:=dx(a1),確認後即可將a1所表示的小寫數字金額轉換為大寫的數字金額,並在a2單元格中顯示出來。怎麼樣,方便吧?