Hi,
I've been having a problem trying to come up with a VBA loop. Here's what I'm trying to accomplish. I have a spreadsheet looking at potential orders based on availability/selling. However, certain times require a set amount of units to reach a discount, minimum quantities set by the vendor, etc.
My spreadsheet will let me know the "recommended" order. However, due to selling or other factors, this number will be short from the "needed" or "desired" quantity to order. I want to add one unit to the lowest number in the "Weeks of Supply" column. This way, if I have to add an additional unit, it's going to something that will sell the quickest and needs it, comparatively, the most.
For example:
I want to order 16 units. The recommendations are as such.
S - 4
M - 2
L - 1
XL - 6
13 units were recommended but I need 16 to place the order.
Here's my VBA Loop that I need:
Look at Cell T5 (where my remaining units to add are)
If T5 =0 Then Do nothing
If T5<>0 Then Find smallest value in range U7:U107 (I have some interesting size ranges but 100 should cover it)
Offset by (0,-2) (In column S. This is where I have the recommended units per size broken out)
Add 1 to that Cell in Column S
Subtract 1 from T5
Loop
This will then loop and stop because T5 will eventually = 0 but the WOS will change as you add 1 unit at a time.
Let me know if you have any questions! I REALLY APPRECIATE ANY HELP. See attached for the screenshot. (*Please ignore the Rounding Column. It's for a different function in the sheet)
Capture.PNG
Bookmarks