+ Reply to Thread
Results 1 to 5 of 5

Loop stop at first hit?

  1. #1
    Registered User
    Join Date
    05-08-2017
    Location
    Paris
    MS-Off Ver
    2013
    Posts
    35

    Loop stop at first hit?

    Dear experts,

    I have a loop on my vba code and it does not work; it only shows one value.

    Purpose of the code:

    For every "TRUE" in column C (3) for the rows 3 to 33 I want the code to copy the value of cell in colum B (2) for the rows 3 to 33 and paste them in the first empty cell under column ZZ. So when the loop works all the columns should be under eachother in column ZZ. However when I run this code it will only give me the 1 single value which is the last one in the entire data sheet that has TRUE indeed. So I guess my loop has an error.

    Can you please advise?

    Thanks you!

    B



    Please Login or Register  to view this content.
    Last edited by alansidman; 06-06-2017 at 05:51 PM. Reason: code tags added

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Loop stop at first hit?

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Loop stop at first hit?

    Move your line for next row to just below your j = 3 to last row.

    It is continually overwriting your next row variable and not incrementing it.

    To be sure of this, run a debug on your existing code Step into the Code by using F8 and see what happens with each line.

  4. #4
    Registered User
    Join Date
    05-08-2017
    Location
    Paris
    MS-Off Ver
    2013
    Posts
    35

    Re: Loop stop at first hit?

    Dear Alansidman,

    Thank you so much for helping me out on this one, it works perfectly now. Next time I will check the forum rules first, thanks a lot for making the adjustments. I very much appreciate your help!

    Thanks!

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Loop stop at first hit?

    You are welcome.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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] Why does my For Loop stop at 1???
    By nickersonpower in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-10-2017, 12:00 PM
  2. how to stop For Loop and Next
    By Anvuri in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-10-2014, 02:12 PM
  3. How to Stop a Do While Loop at a certain row??
    By jtemp57 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-27-2014, 09:53 AM
  4. [SOLVED] how to stop this loop....
    By vimalanathk in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-03-2013, 03:45 AM
  5. How to stop the for loop?
    By ccs1981 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-25-2008, 07:33 AM
  6. Hot key to stop a LOOP
    By joopdog in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-09-2006, 02:51 PM
  7. Stop a loop
    By Matthew McManus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-11-2005, 04:55 AM

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