+ Reply to Thread
Results 1 to 10 of 10

Closing loop

  1. #1
    Forum Contributor
    Join Date
    12-02-2013
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    112

    Question Closing loop

    Please Login or Register  to view this content.

    Hi,

    The above code is required to end running after j reaches to 100 and i reaches to 300, but even after i=300 & j=100 the code again operates from the begining.
    Are there any modifications to be done for the code to stop Lopping, after reaching the maximum values of i & j?

    Thank you

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Closing loop

    I don't think it will go beyond the defined loop counter

    Please Login or Register  to view this content.
    Your code should run as you described


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor
    Join Date
    12-02-2013
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: Closing loop

    yes it runs , that is fine, but it runs twice starting again from the beginning which is the major problem.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Closing loop

    how are you starting the code?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Forum Contributor
    Join Date
    12-02-2013
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: Closing loop

    The code is coded below . The only thing i`am after is to end that "for" statement.

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Closing loop

    how are you running it? button? f5? macros dialog?

    that code will only loop as you described unless you run it twice.

  7. #7
    Forum Contributor
    Join Date
    12-02-2013
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: Closing loop

    iam running the code using RUN button in VB

  8. #8
    Forum Contributor
    Join Date
    12-02-2013
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: Closing loop

    How to exit "FOR" & or "Next" After the Loop has run once?

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Closing loop

    you use exit for or exit sub depending what you want to do but that code will only run the two loops once unless something else is calling it again like a change event or beforesave

  10. #10
    Forum Contributor
    Join Date
    12-02-2013
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: Closing loop

    no need to go after all those problematic solutions, instead I did added 200 to "i" , which proved as a short & powerful desired solution,
    Anyways thanks to everyone participating in solving my Problem.

    Cheers

+ 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. Excel 2013 not closing after closing workbook
    By SBennett212 in forum Excel General
    Replies: 4
    Last Post: 04-04-2015, 11:07 AM
  2. Make a loop for disable closing the UserForm
    By zeko90 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-04-2014, 07:29 AM
  3. Creating new workbook, saving as csv and then closing - but closing always fails.
    By ella626 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-28-2014, 10:05 PM
  4. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  5. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM
  6. [SOLVED] SQL query interrupted by a for loop and closing/saving files
    By nErD in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-10-2012, 04:02 AM
  7. closing a workbook without saving and closing a workbook with saving enabled
    By stanigator in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2007, 02:15 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