+ Reply to Thread
Results 1 to 2 of 2

Loop

  1. #1
    Registered User
    Join Date
    01-28-2011
    Location
    Quebec, Canada
    MS-Off Ver
    Excel 2007
    Posts
    1

    Loop

    hi,

    please dear god someone help me...

    i'm stuck in an endless loop and i cannot for the life of me figure out why... i figure you guys will know.

    please trust that all my variables are initiated properly, and are not empty... this is in a module, contained in a sub.

    here's my code:
    Please Login or Register  to view this content.
    as you can see, i've even tried to set the UsedRange cells into a variable thinking that my adding a value inside the cell was somehow changing the UsedRange request.

    Now here's the very weird part, if i change this line:
    Sheet3.Cells(Cell.Row + 1, Cell.Column).Value = values(CInt(notfoundarr(i)))

    For this line:
    Sheet3.Cells(Cell.Row + 1, Cell.Column + 1).Value = values(CInt(notfoundarr(i)))

    everything works fine, but the value is not in the right column in the new row.

    please help!! :S

    Matt

  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

    Hi Matt

    I suspect your problem is because you're working from the top down. When inserting (or deleting) rows, iterate through the range from the bottom up. Working top down when doing insertions or deletions, Excel gets "lost".

    Do a search on "loop through range backward vba". If you can't get it sorted out, let me know.
    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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