+ Reply to Thread
Results 1 to 8 of 8

how to make a for next loop dynamic

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    how to make a for next loop dynamic

    i have the following:

    Please Login or Register  to view this content.
    how can i dynamically change the start and end variables to new values?
    Last edited by dmcgov; 05-14-2021 at 11:49 AM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: how to make a for next loop dynamic


    Unclear … Maybe just using an InputBox, some cells, some … ?

  3. #3
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: how to make a for next loop dynamic

    Hi, I get an error when I try to use the reserved word "End" as you do, so I changed this variable into "halt" (It is never a good idea to use reserved words as variables)
    I have this solution for you:
    Please Login or Register  to view this content.
    Cheers
    Erwin
    I started learning VBA because I was lazy ...
    Still developing.... being more lazy...

  4. #4
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: how to make a for next loop dynamic

    If you want to continue counting you could add this line after the IF statement:
    Please Login or Register  to view this content.
    Cheers
    Erwin

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: how to make a for next loop dynamic


    As nothing is 'dynamic' under Excel, just following the procedure in step-by-step debug mode …

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: how to make a for next loop dynamic


    In fact the 'dynamic' way is to not use any For … Next loop as obviously not 'dynamic'

    but just some 'dynamic' loop block like While … Wend or Do … Loop with the variables accordingly …

  7. #7
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to make a for next loop dynamic

    thanks eastwood, that did the trick.

  8. #8
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: how to make a for next loop dynamic

    You are welcome.
    If my assistance has helped, and only if you wish to, there is a reputation icon * on the left hand side - you can add to my reputation here.

    Cheers
    Erwin

+ 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. dynamic for loop
    By lastnn30 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-08-2021, 09:01 AM
  2. [SOLVED] How to make a Loop
    By Chandria in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-08-2019, 08:06 PM
  3. Dynamic VBA Loop
    By tejay in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2015, 04:27 AM
  4. Can Someone Take My VBA and make it a for loop?
    By chaddug in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2013, 01:53 PM
  5. Make a loop that goes around around and around
    By Kristian Nilsson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-25-2012, 12:12 PM
  6. Make dynamic charts more dynamic
    By Milo in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-12-2006, 04:10 AM
  7. I want to make one loop
    By David in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2005, 09:05 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