- Sub 排产()
- Dim arr, brr(), i, j, n, b, a
- Sheet2.Range("I6:XFD1000").ClearContents
- arr = Sheet2.Range("a6:g12")
- ReDim brr(1 To UBound(arr), 1 To 31)
- n = 0
- b = 0
- For i = 1 To UBound(arr)
- If arr(i, 4) <> "" Then
- If i = 1 Then
- a = Int(arr(i, 4) / arr(i, 7))
- For j = n + 1 To a
- n = n + 1
- brr(i, j) = arr(i, 7)
- brr(i, j + 1) = arr(i, 4) Mod arr(i, 7)
- Next j
- b = n
- n = 0
- Else
- If brr(i - 1, b + 1) > arr(i, 7) Then
- ss = 0
- Else
- ss = arr(i, 7) - brr(i - 1, b + 1)
- End If
- brr(i, b + 1) = ss
- a = Int((arr(i, 4) - ss) / arr(i, 7))
- For j = b + 2 To a + b + 1
- n = n + 1
- brr(i, j) = arr(i, 7)
- brr(i, j + 1) = (arr(i, 4) - ss) Mod arr(i, 7)
- Next j
- b = b + n + 1
- n = 0
- End If
- ss = ""
- End If
- Next i
- Sheet2.[I6].Resize(UBound(brr), 31) = brr
- End Sub
复制代码 |