+ Reply to Thread
Results 1 to 3 of 3

loop works for one but causes error for other data

  1. #1
    Registered User
    Join Date
    10-15-2010
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2007
    Posts
    56

    Talking loop works for one but causes error for other data

    I have a loop that works for one sheet, and when i have about 40,000 lines it works fine. But then i have some other data, which is about 500,000 lines, & when i split it into 20,000 or however it causes an error in the loop. The loop runs, but then eventually says theres too much data & afterwards it wont save either and the loop wont run.

    Please Login or Register  to view this content.
    any help and guidence on this data error, is the data corrupted? Do I need to paste the data as special values of some time in order for the loop to continue to run. Sometimes it runs about 15,000 rows and then crashes, then i tried doing 4,000 rows but then crashes at 3,000 rows (the second program).

    any help, appreciated,
    Attached Files Attached Files
    Last edited by gill389; 02-24-2011 at 08:21 AM. Reason: solved

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: loop works for one but causes error for other data

    Hi gill389

    In both instances you're looping through over a million rows (column B has NO data in either of your worksheets). At a minimum, I'd suggest finding the last row used in your data with something like this
    Please Login or Register  to view this content.
    and then set your range with something like this
    Please Login or Register  to view this content.
    This will limit your loop to only rows that contain data.

    I don't know what you're trying to do. To eliminate loops altogether, you might think about filtering the data on "1324I" and then do your thing.

    I'd need to know more to advise you on this.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    10-15-2010
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2007
    Posts
    56

    Talking Re: loop works for one but causes error for other data

    What I am doing is shifting the cells to the right, I needed the data organized and had about 1/2 million rows. The data were all organized in different rows under one another, and they needed to be shifted so then I can have a matrix of the data in 1 column. It ran about every 4 needs to be in 1 column.

    When I added "
    LastRow = Cells.Find("*", Cells(Rows.Count, Columns.Count), SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious).Row "
    and then set the range the program ran slower- but it worked great, I cant complain, it didnt crash.

    Thank you for taking the time out to reply, appreciate your 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