|
<P>'***********************小写金额分栏处理过程*************************
'
'Amount为金额,rngTarget为目标存放单元格区域,可选参数blnFoutou确认是否加人民币符号
'
'
Sub AmountXiaoxie(Amount As Double, rngTarget As Range, Optional blnFengTou As Boolean = False)
'定义封头
Const Fengtou As String = "¥"
'最大数字位数
Const Bigdigit = 12
'存放小写数据区域
Dim strXiaoxie(Bigdigit) As String
'临时字符串
Dim strTemp As String
'小写位数
Dim DigitCount As Integer
Dim i As Integer
'小写数字区域
Set rngXiaoxie = rngTarget
'临时数字字符串
strTemp = CStr(Int(Amount * 100))
'数字位数
DigitCount = Len(strTemp)
'数据位数是否超出限制
If DigitCount > Bigdigit Then
Exit Sub
End If
'为数组赋值过程
i = Bigdigit
Do Until DigitCount = 0
strXiaoxie(i) = Mid(strTemp, DigitCount, 1)
DigitCount = DigitCount - 1
i = i - 1
Loop
'是否添加封头
If blnFengTou Then strXiaoxie(i) = Fengtou
'使用formulaarray属性为单元格区域赋值
rngTarget.FormulaArray = strXiaoxie
End Sub</P><P>这是我下面这个帖子中的小写处理过程</P><P><a href="http://club.excelhome.net/viewthread.php?tid=35860&replyID=129293&skin=1" target="_blank" >http://club.excelhome.net/viewthread.php?tid=35860&replyID=129293&skin=1</A></P> |
|