作者yougetit1999 (清)
看板Visual_Basic
標題Re: [VBA ] 數字轉中文大寫的問題
時間Tue Oct 4 15:23:17 2005
※ 引述《yougetit1999 (清)》之銘言:
: 請問我利用EXCEL本身的數字轉中文大寫的時候,11都轉成
: 壹拾壹,請問我要怎樣寫一個判斷式,當10~19時,都會去
: 掉前面的壹呢,因為10寫成壹拾真的蠻奇怪的...
: 謝謝
我寫出一個方法,雖然可以用,但是好像有點笨
能否幫我看一下,是不是能在把程式精簡一下
Dim num As Integer
num = ActiveCell.Value
If num <= 0 Then
MsgBox "輸入錯誤,數值小於0"
ElseIf num > 0 And num < 10 Then
ActiveCell.NumberFormatLocal = "[dbnum2]"
ElseIf num > 19 Then
ActiveCell.NumberFormatLocal = "[dbnum2]"
ElseIf num = 10 Then
ActiveCell.Value = "拾"
ElseIf num = 11 Then
ActiveCell.Value = "拾壹"
ElseIf num = 12 Then
ActiveCell.Value = "拾貳"
ElseIf num = 13 Then
ActiveCell.Value = "拾參"
ElseIf num = 14 Then
ActiveCell.Value = "拾肆"
ElseIf num = 15 Then
ActiveCell.Value = "拾伍"
ElseIf num = 16 Then
ActiveCell.Value = "拾陸"
ElseIf num = 17 Then
ActiveCell.Value = "拾柒"
ElseIf num = 18 Then
ActiveCell.Value = "拾捌"
ElseIf num = 19 Then
ActiveCell.Value = "拾玖"
End If
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.70.60.138