Results 1 to 7 of 7

Loop through rows and generate new records

Threaded View

  1. #1
    Registered User
    Join Date
    09-21-2014
    Location
    DK
    MS-Off Ver
    MS 2013
    Posts
    3

    Loop through rows and generate new records

    First of all - great site. I have been reading through the forum for quite some time and have found many threads quite valuable. But it is time to create a thread for my own since I have not been able to find a discussion for my question.

    I am building a simplified re-order point system - if inventory position drops below a certain level (the yellow level is this case) one or more purchase order lines has to be created in another worksheet.

    I have one worksheet with the following field and data:

    ItemId....Red....Yellow....Green....Multiple....Inventory position

    0001.... 10.... 30.... 50.... 5.... 45

    0002.... 5.... 40.... 47.... 5.... 23

    0003.... 11.... 20.... 30.... 10.... 5

    I would like to generate new rows (in another worksheet) based on the above fields and three rows.

    Basically the end result should look as the following:

    ItemId....Qty....Start inv....Aggregated inventory....Prioritization

    0002.... 5.... 23.... 28.... Yellow

    0002.... 5.... 28.... 33.... Yellow

    0002.... 5.... 33.... 38.... Yellow

    0002.... 5.... 38.... 43.... Green

    0002.... 5.... 43.... 48.... Green

    0003.... 10.... 5.... 15.... Red

    0003.... 10.... 15.... 25.... Yellow

    0003.... 10.... 25.... 35.... Green

    The logic is quite simple - if inventory position is less than the yellow value new order lines should be created in multiple qty (based on the multiple field) until the aggregated value (in worksheet 2) is above the green value.

    The priotization value should be based on the start inv (in ws 2) compared to the values in red, yellow and green in ws 1.

    It would be much valuable if someone could guide me in the right direction towards an appropriate VBA design. I have found some code online which could solve the frame structure but I am looking for what to place into the middle of the code section.

    Sub Test2()
          ' Select cell A2, *first line of data*.
          Range("A2").Select
          ' Set Do loop to stop when an empty cell is reached.
          Do Until IsEmpty(ActiveCell)
             ' Insert your code here.
             ' Step down 1 row from present location.
             ActiveCell.Offset(1, 0).Select
          Loop
       End Sub

    I am looking forward some great answers.

    Much appreciated - thank you in advance.
    Last edited by alansidman; 09-21-2014 at 08:56 AM. Reason: code tags added

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA to rearrange 11000 records into 550 rows (20 records combined into a single row)
    By Wedge120 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-27-2014, 11:56 PM
  2. [SOLVED] Generate List of Records that Match Multiple Criteria from Data Table
    By trandle in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-10-2014, 04:43 PM
  3. [SOLVED] Re: Loop through the rows and extract unique email id's to generate email drafts
    By spiwere in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 01-28-2014, 04:12 AM
  4. Loop to generate TextBox
    By Phoenix5794 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-11-2012, 09:36 AM
  5. How to generate lottery numbers from past records
    By icongene in forum Excel General
    Replies: 5
    Last Post: 06-24-2012, 06:21 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