作者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