+ Reply to Thread
Results 1 to 9 of 9

Loop not finishing

Hybrid View

  1. #1
    Registered User
    Join Date
    08-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    6

    Loop not finishing

    My loop is not finishing all the way and keeps stopping a few columns down. I'm not experienced at this, so it's hard to figure it out.

    It is Macro 9 that I am using btw.
    Attached Files Attached Files

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Loop not finishing

    What Exactly are you wanting to do?
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    05-18-2012
    Location
    Norwalk, CT
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Loop not finishing

    This is a loop of a recorded macro. If you run the macro with a different cell selected, different things will happen.

    You need to post what you are doing.

  4. #4
    Registered User
    Join Date
    08-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Loop not finishing

    I am cutting all all rows from 101-the end and pasting them in the open cell in row 1 until there are no more rows past 100 in the entire worksheet. I am trying to unstack the data to where all of the headers are in row 1 instead of stacked the way they are. The data used to be in 4 columns btw.

  5. #5
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Loop not finishing

    Looking at you sample worksheet Im still confused?
    The data used to be in 4 columns btw.
    in the sample data goes to column BH. Can you upload a Sample of the data in its original format, and on sheet 2 show how you would like it to look.

  6. #6
    Registered User
    Join Date
    08-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Loop not finishing

    The original is on sheet 2
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Loop not finishing

    Try this,

    With the original data in sheet 2 of the second sample, select A1 and run the code, with the earlier sample, select BE1 and run it.

    Sub move_data()
    Application.ScreenUpdating = False
    Dim rng As Range, ctr As Long
    Set rng = Intersect(ActiveSheet.UsedRange, ActiveCell.Resize(1, 4).EntireColumn)
    ctr = 1
    Do Until rng.Rows.Count - (ctr * 100) < 0
        Range(rng((ctr * 100) + 1, 1), rng((ctr * 100) + 100, 4)).Cut rng.Offset(, ctr * 4)
        ctr = ctr + 1
    Loop
    Application.ScreenUpdating = True
    End Sub
    Last edited by jason.b75; 08-14-2012 at 10:41 AM.

  8. #8
    Registered User
    Join Date
    08-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Loop not finishing

    Is there any way I can change the loop I have in place so that it will work? I'm trying to use the recorded macro so I can use a similar loop for other data without having to know how to actually write code. Lazy, I know, but I don't have the time unfortunately.

    ---------- Post added at 09:48 AM ---------- Previous post was at 09:42 AM ----------

    Nevermind, this works awesome. Thanks a bunch, I appreciate it.

  9. #9
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Loop not finishing

    Quote Originally Posted by boomersooner5136 View Post
    so I can use a similar loop for other data
    Will the 'similar' loops still be using the same cut and paste data in fixed size blocks?

    The code in my previous post can be made more generic so you can use it on any size range if that would help?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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