|
- Sub 按金额拆分数字()
- MAXDOU = CSng(InputBox("请输入开票限额", "温馨提示", 120000))
-
- Rem 清除数据
- Set SHX = Worksheets("Sheet1")
- SHX.Range("H2:K1048576").ClearContents
- INTX = 0
- MAXROW = SHX.Range("A38").End(3).Row
-
- For I = 2 To MAXROW
- DOUX = SHX.Cells(I, 3).Value '//金额
- DOUG = SHX.Cells(I, 2).Value '/数量
- DOUJ = DOUX / DOUG '//单价
- Rem 计算最少几张发票
- If DOUX Mod MAXDOU > 0 Then
- Rem 有余数+1
- Pages = Int(DOUX / MAXDOU) + 1
- Else
- Rem 整除 不+1
- Pages = Int(DOUX / MAXDOU)
- End If
-
- For X = 1 To Pages
- If DOUX > 0 Then
- Rem 每张发票的信息
- INTX = INTX + 1
- SHX.Cells(INTX + 1, 8).Value = INTX
- SHX.Cells(INTX + 1, 9).Value = SHX.Cells(I, 1).Value
- If DOUX >= MAXDOU Then
- SHX.Cells(INTX + 1, 11).Value = MAXDOU
- SHX.Cells(INTX + 1, 10).Value = WorksheetFunction.Round(MAXDOU / DOUJ, 2)
- DOUG = DOUG - WorksheetFunction.Round(MAXDOU / DOUJ, 2)
- DOUX = DOUX - MAXDOU
- Else
- SHX.Cells(INTX + 1, 11).Value = DOUX
- SHX.Cells(INTX + 1, 10).Value = DOUG
- DOUX = 0
- End If
- End If
- Next
- Next
- MsgBox "OK", , "北极狐工作室QQ:14885553"
- End Sub
复制代码 |
|