+ Reply to Thread
Results 1 to 14 of 14

VBA - Not going to next in loop

  1. #1
    Registered User
    Join Date
    09-19-2016
    Location
    Muscat, Oman
    MS-Off Ver
    365
    Posts
    56

    VBA - Not going to next in loop

    Can someone help me? I made this and for some reason it does not go to the 2nd row, unless I am in Step Into. But run by itself, it just continues without stop.

    I am hoping that when you read it, you will easily see where I went wrong. I appreciate your advice in advance!

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: VBA - Not going to next in loop

    Which loop... the commented out one or one of the other ones? If one of the others, which one?

  3. #3
    Registered User
    Join Date
    09-19-2016
    Location
    Muscat, Oman
    MS-Off Ver
    365
    Posts
    56
    Quote Originally Posted by Rick Rothstein View Post
    Which loop... the commented out one or one of the other ones? If one of the others, which one?
    The colmun loop. I think that is the one that gets hung up. But could be wrong.

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: VBA - Not going to next in loop

    Is that the one you commented out?

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,359

    Re: VBA - Not going to next in loop

    @Rick: guessing it's this ...

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Registered User
    Join Date
    09-19-2016
    Location
    Muscat, Oman
    MS-Off Ver
    365
    Posts
    56

    Re: VBA - Not going to next in loop

    Quote Originally Posted by Rick Rothstein View Post
    Is that the one you commented out?
    The column loop is not commented out. Sorry, I did not understand.

    The problem is that it does not go to the next rownum. So I was thinking that the loop TMS quoted it not finishing correctly. I was hoping that an expert eye could see the mistake, as I cannot after spending 2 days Debugging.

  7. #7
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: VBA - Not going to next in loop

    Try row 208 in the attached .pdf spelling of variable 'colnum' is spelled wrongly as 'colmun'
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    09-19-2016
    Location
    Muscat, Oman
    MS-Off Ver
    365
    Posts
    56

    Re: VBA - Not going to next in loop

    Thank you for pointing that out. Okay, I fixed that. But I don't believe thats my only problem.

  9. #9
    Registered User
    Join Date
    09-19-2016
    Location
    Muscat, Oman
    MS-Off Ver
    365
    Posts
    56

    Re: VBA - Not going to next in loop

    Okay, it appears to be working now. So maybe it was the misspelling or another small changes made. Thank you guys for your guidance!

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,359

    Re: VBA - Not going to next in loop

    So maybe it was the misspelling ...
    Looks pretty likely given the context of the block

    Please Login or Register  to view this content.

    Use Option Explicit at the top of every module to avoid misspelling variable names.




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  11. #11
    Registered User
    Join Date
    09-19-2016
    Location
    Muscat, Oman
    MS-Off Ver
    365
    Posts
    56

    Re: VBA - Not going to next in loop

    I have one more question about this VBA. Is there a way to speed it up? I ran it overnight last night (6.5 hrs) and it calculated 188 rows. I have over 100,000 rows per workbook. That would be 2.9 million hours to complete one workbook....and I have 22 workbooks todo.

    Specifically, my question pertains to advice regarding:
    * writing the code to be a lot more efficient
    * Is there another method to calculate this quicker
    * like Access Database
    * another computation software
    * etc.

    One of my computers has 32 cores, 128 GB of ram. Plus I ran it on a second computer at the same time. It only has 4 cores and 16 GB ram. It computed at the same pace. As they say, VBA is not multi-threading, so I eliminated the computer hardware as not a solution.
    Last edited by stearno; 09-28-2020 at 11:14 PM.

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,359

    Re: VBA - Not going to next in loop

    You have the advantage of us ... you have the data, the code, and you know what you are trying to do with it.

    In general terms

    1. Switch off screen updating
    2. Set Calculation mode to Manual
    3. Switch off Event Handling
    4. Avoid selecting cell/rows/columns/worksheets etc
    5. Avoid full column references in formulae, especially Array Formulae and SUMPRODUCT
    6. Check Conditional Formatting ... might be worth clearing it and reinstating it
    7. Some people would advocate reading the entire sheet into an array, processing it, and dropping the result back
    8. It may be something Power Query can handle but that's not my area of expertise

  13. #13
    Registered User
    Join Date
    09-19-2016
    Location
    Muscat, Oman
    MS-Off Ver
    365
    Posts
    56

    Re: VBA - Not going to next in loop

    Quote Originally Posted by TMS View Post
    You have the advantage of us ... you have the data, the code, and you know what you are trying to do with it.

    In general terms

    1. Switch off screen updating
    2. Set Calculation mode to Manual
    3. Switch off Event Handling
    4. Avoid selecting cell/rows/columns/worksheets etc
    5. Avoid full column references in formulae, especially Array Formulae and SUMPRODUCT
    6. Check Conditional Formatting ... might be worth clearing it and reinstating it
    7. Some people would advocate reading the entire sheet into an array, processing it, and dropping the result back
    8. It may be something Power Query can handle but that's not my area of expertise
    Understood. Thank you for the advice! Will give it a try.

  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,359

    Re: VBA - Not going to next in loop

    You're welcome. Thanks for the rep.

+ 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. Loop through emails to find Email today, if not found loop Date -1
    By lougs7 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2020, 12:48 PM
  2. [SOLVED] VBA to loop through cell-defined range and paste table output after each loop.
    By mscott123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-18-2019, 03:41 AM
  3. Replies: 13
    Last Post: 07-08-2018, 05:22 AM
  4. [SOLVED] (Beginner help) For loop inside do loop that displays information from reference sheet.
    By lediable007 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-08-2016, 03:20 PM
  5. [SOLVED] Auto email loop with formatted table data breaking on second loop VBA
    By Who_else in forum Excel General
    Replies: 6
    Last Post: 03-24-2016, 06:22 AM
  6. [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
  7. 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

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