+ Reply to Thread
Results 1 to 6 of 6

Ending a do loop with an exact cell or column.

  1. #1
    Registered User
    Join Date
    11-17-2014
    Location
    Moscow, ID USA
    MS-Off Ver
    2013
    Posts
    3

    Ending a do loop with an exact cell or column.

    Brand spanking new to this VBA fun and ran into a problem. I have been working on transferring data from a easy to enter spreadsheet to a better to look at the data spreadsheet. This part of the macro is working perfectly now, but it is written to copy at the next available blank, so if there are blanks in the middle of the data, it writes over into the wrong field. I have missed hand filling in these blanks with "-" a couple times and thought a quick "Prep" macro would do the trick for me.

    To my understanding, I have a code written out to start at a specific cell, go to the next available blank, and fill it with "-". The issue I am finding is I can't find a way to stop the loop at a specific cell. In the example below b51. Please take a look and let me know what I am doing wrong. Once again I am very new so please pretend you are explaining this to a moron...

    Thank you in advance!

    Please Login or Register  to view this content.
    I based this off of what has been working great for me:

    Please Login or Register  to view this content.
    Last edited by Lankkari; 11-17-2014 at 11:51 PM.

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Ending a do loop with an exact cell or column.

    Hi Lankkari,

    Welcome to the forum!!

    See if changing this line of code...

    Please Login or Register  to view this content.
    ...to this does the job:

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Ending a do loop with an exact cell or column.

    This should do it:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    11-17-2014
    Location
    Moscow, ID USA
    MS-Off Ver
    2013
    Posts
    3

    Re: Ending a do loop with an exact cell or column.

    Thank you Robert! That worked perfectly.

  5. #5
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Ending a do loop with an exact cell or column.

    Thank you Robert! That worked perfectly.
    You're welcome and thanks for marking the thread as solved

  6. #6
    Registered User
    Join Date
    11-17-2014
    Location
    Moscow, ID USA
    MS-Off Ver
    2013
    Posts
    3

    Re: Ending a do loop with an exact cell or column.

    So I tried both mentioned methods to accomplish what I was trying to do and found that
    Please Login or Register  to view this content.
    worked fine when there was only a few rows to add "-" to. When I would attempt to add another snippet just like this but for the next column over, it would continue without stopping. I also found that if I would delete all data in the original column "d" then the loop seemed for freeze at rows 21-22... To help this is the exact code I was using when all of this happened.
    Please Login or Register  to view this content.
    Again, this worked fine when only 5-6 rows at the bottom needed filling but didn't when the whole column was empty to start with. Or, when an identical code was added with the range being changed to "e15" and "$E$51" respectively.

    On the other hand. The second snippet of code works great and made the whole process easier because the range can be easily adjusted and it functions just the same.

    Not sure what isn't quite right with this first line of code, but glad the second one works so well.

    Thanks for all the 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] Do Until loop not ending
    By Dralky in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-15-2014, 09:57 PM
  2. Do until Loop not ending
    By Alexm963 in forum Word Programming / VBA / Macros
    Replies: 6
    Last Post: 12-28-2012, 05:09 PM
  3. [SOLVED] ending a sub FOR loop in a main FOR loop
    By samkumar in forum Word Programming / VBA / Macros
    Replies: 2
    Last Post: 09-27-2012, 05:35 AM
  4. Ending a Loop
    By kirsty in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-25-2010, 01:11 PM
  5. Never ending loop
    By Theodjinn in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-23-2008, 04:08 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