+ Reply to Thread
Results 1 to 11 of 11

Problem with looping

  1. #1
    Registered User
    Join Date
    09-25-2016
    Location
    Florida
    MS-Off Ver
    365
    Posts
    54

    Problem with looping

    Hello,

    I've never fully understood the "looping" process and for each time I've had a requirement I've had to go asking for help. Each time I've read and read and tried umpteen examples to no avail. Attached, for this instance, is what I have after I cleaned up my crazy, messy and just more or less guessing efforts. I'm hoping if someone can help me figure this out then maybe it'll be that little bit more to help me better understand it.

    This code does the trick row by row with each button click but I want it to "loop" through all the rows with one click until the last item.

    Any help is greatly appreciated!

    Andy

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,716

    Re: Problem with looping

    Re: "This code does the trick row by row"

    Maybe explain what you want to do in a concise way.
    When volunteers give you a solution, it might be different from what you have. At that time you can ask for a looping solution.
    The inherent weakness of the liberal society: a too rosy view of humanity.

  3. #3
    Registered User
    Join Date
    09-25-2016
    Location
    Florida
    MS-Off Ver
    365
    Posts
    54

    Re: Problem with looping

    It's taking the information off of each cell in each row when column "X" has "6. Shipped".... hence the offsets. I want it to move to the next row with "6. Shipped" and perform the same function until "6. Shipped" is no longer in column range "X3:X228".

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,993

    Re: Problem with looping

    So...Wanting to clear the row if Col X contains "6. Shipped"
    Or only cells for specific columns i.e. B | D | K | X & Y

    Please upload a small sample showing before | after result
    Last edited by Sintek; 06-24-2024 at 01:11 PM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,716

    Re: Problem with looping

    To stay close with what you showed.
    Please Login or Register  to view this content.
    There is better ways of solving your problem, that's why my question im the previous post to make sure I understand your requirement properly.

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,993

    Re: Problem with looping

    Non looping option...

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-25-2016
    Location
    Florida
    MS-Off Ver
    365
    Posts
    54

    Re: Problem with looping

    Hi Joli,

    That works exactly as intended...at least the way I was approaching it. I think the biggest problem for me was not using the "with". But the "lr as Long" I don't completely understand because it looks as if your going all the way down the column and back up to find "6. Shipped" but yet it starts with the top "6. Shipped". This gets me further along with my understanding of loops. I'm not a VBA guru but good enough to be dangerous.

    Thank you,
    Andy

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,716

    Re: Problem with looping

    Normally it is better to use the "lr" statement for last used cell in a column. That way you don't have to hard code a value in your code.
    There are a lot of different ways to calculate "lr". This is just one of the possibilities.

    As stated in my last line of Post #5 about better ways, you should try "Master Magician" Sintek's suggestion also.

  9. #9
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,993

    Re: Problem with looping

    Master Magician" Sintek'
    Far from it...Just like you...I too just learn daily from the Masters here...
    Sometimes I don't even know what I'm doing...As my signature says...
    One day one problem at a time...
    Last edited by Sintek; 06-24-2024 at 02:40 PM.

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,716

    Re: Problem with looping

    All in good fun Sintek.
    At least we understand that there is no limit to expanding our knowledge and horizon.

    The reason I said that though is because you,ve suggested some fantastic, in my mind anyway, solutions in threads I followed.
    Keep up the good work.
    Last edited by jolivanes; 06-24-2024 at 03:19 PM.

  11. #11
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,993

    Re: Problem with looping

    @ jolivanes...
    Fun to be able to contribute & learn at the same time...
    Tx...Happy Coding...

+ 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. Looping Problem
    By SKT49 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2015, 02:52 AM
  2. [SOLVED] Looping problem
    By bibu in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-27-2014, 06:09 AM
  3. [SOLVED] Looping Problem
    By Varun13 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2012, 03:02 PM
  4. Looping Problem
    By Spasm in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 07-09-2011, 02:32 PM
  5. Looping Problem
    By Spasm in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-09-2011, 11:10 AM
  6. Looping Problem
    By carddards in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2008, 12:47 PM
  7. Looping Problem??
    By tubeboy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2005, 12:21 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