+ Reply to Thread
Results 1 to 5 of 5

Loop only runs if-statement one time

  1. #1
    Registered User
    Join Date
    10-09-2017
    Location
    Norway
    MS-Off Ver
    2016
    Posts
    3

    Loop only runs if-statement one time

    Hello,

    Im trying to copy over rows from one sheet to another using a loop and a condition based on the text color. Problem is that it only loops until the first row where the condition is met, copies that row and stops. When runned in step debugging mode everything is functioning properly.

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: Loop only runs if-statement one time

    Hello fokka,

    To be honest in a hastily-prepared sample worksheet attempting to replicate your problem everything worked fine for me...The only thing I see about your code is that it leaves the last copied row selected, maybe that's messing something else up about your code? Maybe throw another sheet selection after the copy:
    Please Login or Register  to view this content.
    I hope that helps. Alternatively, if you don't have sensitive data it is always helpful to upload your actual worksheet so we can all be working in the exact same environment.

    DarkF1ame
    Mark as "Solved" and add Reputation if applicable.

  3. #3
    Registered User
    Join Date
    10-09-2017
    Location
    Norway
    MS-Off Ver
    2016
    Posts
    3

    Re: Loop only runs if-statement one time

    Thank you for the quick reply.

    No difference sadly.

    I can try to mock up a dummy-file to share here and upload

  4. #4
    Registered User
    Join Date
    10-09-2017
    Location
    Norway
    MS-Off Ver
    2016
    Posts
    3

    Re: Loop only runs if-statement one time

    The other workbook must be haunted or something. Everything works in the dummy-file, so i copied everything over there and it's now working perfectly.

  5. #5
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: Loop only runs if-statement one time

    Odd...ghosts in the machine!

    Hope all keeps running well, if not, feel free to ask for more help.

+ 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] Create Loop that runs until Last Worksheet
    By cbramsey1979 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-24-2017, 10:16 AM
  2. If condition not met, but runs the statement.
    By raulge91 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-21-2015, 07:23 PM
  3. vba code throws an error first time but runs perfectly the second time. HELP!!
    By mvneema in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2014, 12:42 PM
  4. Loop runs stuck with sorting
    By nielsBNP in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-17-2013, 10:04 AM
  5. Ok button runs code 17 times w/o loop.... Why?
    By contaminated in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-28-2012, 05:19 AM
  6. [SOLVED] Help with a Do Loop that runs off a VLookup and a Pick list
    By delaneybob in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-14-2012, 09:40 PM
  7. [SOLVED] ADO command.execute with a loop - only runs once
    By George King in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2006, 02:35 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