Trying to minimize leftovers to be as close as possible to 0 but not negative by shifting inventories around
Inventory qty can only move horizontally (i.e., Inventory 1 can't move to inventory 2 or 3)
Inventory qty is already given, each qty is treated as a whole and can't be combined or merged or added or removed
From this:
To this:
It's like taking a snapshot of inventory and relocating them so that the leftovers for each month is as close to 0 as possible.
I've tried something like this but it doesn't seems to work because it's merging the inventories together by adding the qty and it's only moving to the right..
Appreciate the help.
Inventory qty can only move horizontally (i.e., Inventory 1 can't move to inventory 2 or 3)
Inventory qty is already given, each qty is treated as a whole and can't be combined or merged or added or removed
From this:
To this:
It's like taking a snapshot of inventory and relocating them so that the leftovers for each month is as close to 0 as possible.
I've tried something like this but it doesn't seems to work because it's merging the inventories together by adding the qty and it's only moving to the right..
Code:
[COLOR=#333333]<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Sub test()
Dim rw As Integer, col As Integer
Dim dif As Integer
For rw = 6 To 8
For col = 2 To 7
dif = Application.Min(Cells(4, col), Cells(rw, col))
If Cells(4, col) > 0 Then
Cells(rw, col + 1) = Cells(rw, col + 1) + dif
Cells(rw, col) = Cells(rw, col) - dif
End If
Next
Next
End Sub</code>[/COLOR]