+ Reply to Thread
Results 1 to 7 of 7

Loop won't stop looping

  1. #1
    Registered User
    Join Date
    12-12-2013
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    92

    Loop won't stop looping

    I have data on an Import tab. I have a macro built to loop through the names on a build tab and copy information from the import tab. When I step through the macro I get all the necessary information but the loop won't stop.
    Please Login or Register  to view this content.
    Any help is appreciated.

    Additional information: The loop is matching names from each worksheet.
    Last edited by ciresuark; 03-26-2018 at 03:47 PM.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,057

    Re: Loop won't stop looping

    hi ciresuark,

    Without looking at the workbook, it is hard to say exactly what is up. One question that comes to mind right away is this: What is the value of lrow before the loop starts? Have you stepped through the code until say "ws.activate" and then checked the value of lrow? If for some reason that value is 1, then x will never equal lrow since x starts at 2, and the loop would run indefinitely (or until it errors out because the row reference becomes invalid EVENTUALLY)
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    12-12-2013
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: Loop won't stop looping

    That is probably why. lrow is 1019 and it only needs to be 19.

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,057

    Re: Loop won't stop looping

    There must be something in that row... check ws3 ("Build"), and see if A1019 has a space or something?

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Loop won't stop looping

    What's the value of the lrow variable?

    If the Build worksheet column A is empty before you start then presumably it will be the value 1 and since you're starting x at 2 x will never = 1.

    Difficult to comment without seeing the actual workbook.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  6. #6
    Registered User
    Join Date
    12-12-2013
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: Loop won't stop looping

    I deleted A1019 to A19 and the loop is working good now. Thanks!
    I will have to use te msgbox more to double check my variables.

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,057

    Re: Loop won't stop looping

    Glad it was sorted

    Thanks for the rep, and marking the thread as solved!

+ 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] How to stop macro from looping
    By TBM in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-14-2018, 10:10 PM
  2. [SOLVED] How to stop looping in windows 7
    By mohan.r1980 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2016, 07:16 AM
  3. [SOLVED] Loop through strings stop when strings change and start looping in the next column...?
    By Prexcel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-18-2013, 03:31 AM
  4. Stop looping at a specific sheet
    By Bpd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2013, 11:03 PM
  5. [SOLVED] Stop looping
    By cdafonseca in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2013, 11:13 PM
  6. How to stop Macro from looping
    By cooh23 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-27-2007, 01:05 PM
  7. [SOLVED] Do Loop Won't Stop Looping
    By Lost in Alabama in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-22-2006, 08:30 PM

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