+ Reply to Thread
Results 1 to 10 of 10

Need help with my first For Next Loop

  1. #1
    Registered User
    Join Date
    03-09-2017
    Location
    Chicago
    MS-Off Ver
    2010
    Posts
    15

    Need help with my first For Next Loop

    Good afternoon everyone. I need help with my first For Next Loop. What im trying to accomplish is take a set of data all in one column and separate them into different columns. Below is what i have so far. it works for what im trying to accomplish for the most part, but i need some help with a couple tricky outliers. Wondering if someone here could help (where i need help im annotating in bold)
    Please Login or Register  to view this content.
    Last edited by powersml07; 03-13-2017 at 03:15 PM. Reason: code tag

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Need help with my first For Next Loop

    Work your way up from the bottom and then you don't need to keep going up and down and selecting cells.

    Or, just don't cut the cells. Just copy and paste the entries into their respective columns and then delete the source data in one go.

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    03-09-2017
    Location
    Chicago
    MS-Off Ver
    2010
    Posts
    15

    Re: Need help with my first For Next Loop

    Im not sure that would work. The need for those IFs are they need to line up with a SKU. The majority of those SKUs have 5 columns, however the outliers that dont ruined my FOR NEXT Loop. Thats why i had to start to include the IF statements. When those outliers occur, i also need to stop the loop and start it over. Example of how my data would look would be

    Please Login or Register  to view this content.
    What im trying to do is put 100 from ABC SKU and put it in the 3rd column, 250 from ABC to the 4th, 500 to the 5th, 1000 to the 6th. then repeat to the next sku. IF you look at SKU GHI though, you notice that data only has 4 numbers associated with it. Thats where the IF statement would come into play and why i would need it to start at the top of the loop when going to SKU JKL

    hope that helps

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Need help with my first For Next Loop

    That was not what I understood from what you described.

    If column A has blanks, you can check that and store the product row. If it's not blank, you copy (not cut / delete) the value to the next available slot on the product row.

    When you get to the bottom, Filter column A for blanks and delete the visible rows.

    Post a sample workbook with some typical data.

  5. #5
    Registered User
    Join Date
    03-09-2017
    Location
    Chicago
    MS-Off Ver
    2010
    Posts
    15

    Re: Need help with my first For Next Loop

    Hoping this works. Here should be a sample set of data to what ive been working on
    Attached Files Attached Files

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Need help with my first For Next Loop

    What's with the 12 in cell B6?

  7. #7
    Registered User
    Join Date
    03-09-2017
    Location
    Chicago
    MS-Off Ver
    2010
    Posts
    15

    Re: Need help with my first For Next Loop

    my fault. i was just using that 12 value to test one of the IF statements

  8. #8
    Registered User
    Join Date
    03-09-2017
    Location
    Chicago
    MS-Off Ver
    2010
    Posts
    15

    Re: Need help with my first For Next Loop

    Thanks for your help TMS. I figured it out. I just put a GoTo step in the ELSE statement that brought it back up to the top of the LOOP

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Need help with my first For Next Loop

    Try:

    Please Login or Register  to view this content.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Need help with my first For Next Loop

    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] (Beginner help) For loop inside do loop that displays information from reference sheet.
    By lediable007 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-08-2016, 03:20 PM
  2. [SOLVED] Auto email loop with formatted table data breaking on second loop VBA
    By Who_else in forum Excel General
    Replies: 6
    Last Post: 03-24-2016, 06:22 AM
  3. [SOLVED] VBA to loop within a loop of multiple blocks of data (currentregion) ... Expert needed
    By Jim885 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2016, 08:28 PM
  4. Loops with saved variables for each loop to be compared after loop is finished?
    By flabb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2016, 07:48 AM
  5. [SOLVED] Find function in nested loop breaking down - not on first time through loop
    By adamstarr12 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-14-2014, 09:32 AM
  6. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  7. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM

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