Results 1 to 9 of 9

VBA Loop To Add 'left over' Units

Threaded View

  1. #1
    Registered User
    Join Date
    09-16-2014
    Location
    New York, New York
    MS-Off Ver
    2010
    Posts
    6

    VBA Loop To Add 'left over' Units

    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
    Last edited by npb006; 09-16-2014 at 01:37 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 12-15-2013, 11:44 AM
  2. VBA Loop to Look up using Left and Right Function for months
    By bkeat in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2013, 09:30 AM
  3. [SOLVED] For Next Loop - Sort Each Row Left to Right
    By vba_beginner in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-14-2013, 11:54 AM
  4. [SOLVED] Calculate the Bonus units according to the quantity of the units bought (Help)
    By mo_naf in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-15-2012, 05:51 PM
  5. Write a for loop from left to right
    By ccs_1981 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2011, 05:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1