+ Reply to Thread
Results 1 to 8 of 8

Infinite looping problem!!!

  1. #1
    Registered User
    Join Date
    12-11-2013
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    4

    Infinite looping problem!!!

    I'm currently working on a macro for a client and it involves the use of looping. Essentially what I want to do is find every instance where "EERT OUPUT" header is mentioned in the spreadsheet then rearrange the stacked data below the EERT OUTPUT header into one line or row then proceed to the next EERT OUTPUT header perform the same rearranging activities and so on and so forth. The problem is that the EERT OUTPUT sections aren't sequential AND I have an infinite loop and don't know how to exit. The first EERT OUTPUT header would be in cell A16, the three lines of data (covering about 10 columns) would be provided beneath the header, and then the next EERT OUTPUT header wouldn't be found until cell A112. So about every 100 rows or so the EERT OUTPUT header appears, but varies. I've tried a ton of different things with the VBA, but I think I reached the limitations of my knowledge. Here's the VBA I have:

    Please Login or Register  to view this content.
    Also, here's how the spreadsheet is arranged where each letter represents a different data field. I 've provided two additional output groups, but there's probably about 5 or 6 of them. I need to keep the headers, but what I want to do is take the stacked data that is on separate rows and place it on one row. So as you can see the search functionality was used in my macro because the EERT OUTPUT sections are spread out, which makes this macro more complex than your typically loop. So I want to find the first EERT OUTPUT, perform the reorganizing of the data, then move to the next EERT OUTPUT header, perform the same task, and continue until all EERT OUTPUT sections have been reorganized to meet the identified specifications. I also want to be able to continue the macro after exiting the loop and perform additional processes prior to the loop.

    EERT OUTPUT

    A B C D E F G H
    I J K L M N O P
    Q R S T U V W X

    OUTPUT 1
    AB AC AD AE AF
    AG AH AI AJ AL
    AM AN AO AP AQ

    OUTPUT 2
    BC BD BE BF BG
    BH BI BJ BL BM
    BN BO BP BQ BR

    EERT OUTPUT

    A B C D E F G H
    I J K L M N O P
    Q R S T U V W X


    Any help is much appreciated!!!!!
    Last edited by alansidman; 12-11-2013 at 07:49 PM. Reason: code tags added

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,937

    Re: Infinite looping problem!!!

    Rule 03: Code Tags
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between
    Please Login or Register  to view this content.
    tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (I have added them for you today. Please read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    12-11-2013
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Infinite looping problem!!!

    Thanks, my apologies I'm new to the forum. I will make sure to follow this guidance going forward.

    Regarding the infinite loop issue, any assistance you can provide would be great.

  4. #4
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Infinite looping problem!!!

    The best way to improve the chances of getting a solution is to attach a sample Workbook showing your Data and also the desired Result on another sheet..

    Click on the "Go Advanced" button (below and to the right of the "Quick Reply" box).. and then Click on the "manage Attachments" button..

  5. #5
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Infinite looping problem!!!

    You may try:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-11-2013
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Infinite looping problem!!!

    That didn't work. I've attached the spreadsheet; this might help a little better. Note: Actual fields and data have been stripped due to confidential information.
    Attached Files Attached Files

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Infinite looping problem!!!

    May be this:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-11-2013
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Infinite looping problem!!!

    Excellent! Thanks Izandol. That worked perfectly; however, I have one last question.

    I was attempting to replicate your loop for another section of the output (same report but the first loop is 1 of 2 pieces of the report), but it's not working. This loop is definitely more lengthy than the one mentioned in the initial post, but it should still work if I'm using the same logic, right? Could you help me out?? I've attached the spreadsheet for your review. If you can figure this one out, you're the man.
    Attached Files Attached Files

+ 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. problem in looping
    By katie1987 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2012, 06:49 AM
  2. [SOLVED] Looping Problem
    By Varun13 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2012, 03:02 PM
  3. Looping Problem
    By Spasm in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 07-09-2011, 02:32 PM
  4. [SOLVED] Looping problem
    By Sleeping Bear in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2005, 03:05 PM
  5. Looping Problem??
    By tubeboy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2005, 12:21 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