|
楼主 |
发表于 2011-12-14 17:17
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 wqfzqgk 于 2011-12-15 07:30 编辑
- Function splitmoney(rng As Range, i As Integer)
- Dim str As Double, j As Integer, money, num, brr(1 To 13)
- str = Val(rng.Value) * 100
- brr(1) = Int(str / 10000)
- str = str - brr(1) * 10000
- For j = 2 To 13
- money = Choose(j, 10000, 5000, 2000, 1000, 500, 200, 100, 50, 20, 10, 5, 2, 1)
- num = 0
- Do While str - money >= 0
- num = num + 1
- str = str - money
- Loop
- brr(j) = num
- Next
- splitmoney = brr(i)
- End Function
- Sub test()
- Application.MacroOptions "splitmoney", "分离钱币", , , , , "my", , , , Array("选定的范围", "1指100元,2为50元,3为20元,4为10元,5为5元,6为2元,7为1元,8为5角,9为2角,10为1角,11为5分,12为2分,13为1分")
- End Sub
复制代码 |
|