+ Reply to Thread
Results 1 to 10 of 10

Loop until quantity needed met - count in multiples based on item

  1. #1
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Loop until quantity needed met - count in multiples based on item

    Hello,

    I'm looking for a macro that can go down the list of items in the "Need" sheet, determine how many repeats of that item based on the "count by" sheet, and put the result in sheet4. The macro needs to do this for every item in column A of the "Need" sheet.
    An example of the result I am looking for is the "desired output" sheet.

    Thank you for any help!
    Attached Files Attached Files

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Loop until quantity needed met - count in multiples based on item

    Here's a commented macro that should do pretty much what you're after:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Re: Loop until quantity needed met - count in multiples based on item

    Thank you WBD for the detailed response! This does pretty much what I need.
    To answer your question, "don't over order if it's not an exact multiple?" - Overordering is fine. In fact overordering is preferred and I need to stay in exact multiples.

  4. #4
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Loop until quantity needed met - count in multiples based on item

    OK. Then this line changes:

    Please Login or Register  to view this content.
    WBD

  5. #5
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Re: Loop until quantity needed met - count in multiples based on item

    Hey WBD,

    I have a couple of special cases where the order multiple is zero. In this case, I want to skip the item. Right now the macro gets stuck in a loop, constantly subtracting by zero.

  6. #6
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Loop until quantity needed met - count in multiples based on item

    Please Login or Register  to view this content.
    WBD

  7. #7
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,577

    Re: Loop until quantity needed met - count in multiples based on item

    Order multiple of A4 in "Count by" sheet is zero. Hence it will not be displayed.

    Try this Code
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 09-23-2021 at 04:07 AM.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  8. #8
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Re: Loop until quantity needed met - count in multiples based on item

    WBD,

    I see you added the Elseif to check for zero's. The logic makes sense, but the macro doesn't run.
    Maybe is just on my side?
    See attached
    Attached Files Attached Files

  9. #9
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Loop until quantity needed met - count in multiples based on item

    Oops. Should have tested it! See attached.

    WBD
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,577

    Re: Loop until quantity needed met - count in multiples based on item

    Code made faster.
    Order multiple of A4 in "Count by" sheet is zero. Hence it will not be displayed.

    Try this Code
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Formula to count hours/minutes based on multiples cells and instances
    By exceleratevba in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-16-2020, 10:16 AM
  2. [SOLVED] Simple formula needed to count cells based on item names in other cells
    By excelteam777 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-25-2019, 05:49 PM
  3. [SOLVED] I need help on a formula where I find an item and quantity based on a specific date
    By Pickled Shark in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-28-2017, 02:01 PM
  4. Auto decrease quantity of an item when the item is sold.
    By acidust in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-11-2016, 07:46 PM
  5. [SOLVED] VBA To populate listbox with duplicate item by increasing the item quantity
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-01-2016, 07:51 AM
  6. Replies: 6
    Last Post: 01-13-2015, 05:42 PM
  7. fifo value by item computed from observed quantity-by item and-purchase information
    By shifty911 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-10-2014, 06:44 PM

Tags for this Thread

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