+ Reply to Thread
Results 1 to 5 of 5

Nested loops problem

  1. #1
    Registered User
    Join Date
    06-07-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Nested loops problem

    This is my first attempt at using vba. What I'm trying to do is find palindromes that are multiples of three digit numbers. I figured I'd start with 100 and multiply that by 100-999 then jump to 101 times 100-999 and so on untill 999-999 and excel check each number to see if its a palindrome.

    I know my code is ugly but here it is.


    Please Login or Register  to view this content.

    I've added some comments but they most likely make the code hard to read.
    While testing this out I tossed in message boxes to see what wasnt working and it appears the my second loop only happens once.




    What I dont want is a solution to how to find the palindromes, what I would like would be if someone could explain why my second loop isnt restarting.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Nested loops problem

    How about ...

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Nested loops problem

    Hi Symplystyc
    It looks like your y-loop is executing properly
    Try using the Debug statement as follows and watch the Immediate window

    Please Login or Register  to view this content.
    Need some attention to your logic?

  4. #4
    Registered User
    Join Date
    06-07-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Nested loops problem

    Barryleajo, I put in Debug.Print y and nothing happened. any suggestions.

    and thanks shg I didnt even consider using For statements. but now I want to figure out what I did wrong with the Do statements.

  5. #5
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Nested loops problem

    Hi Symplystyc
    Have you got your Immediate window in view?
    In the VBE editor, open it from the View menu.
    It will likely dock as a window at the bottom of the code window.
    This is the only place that you will see anything "happen".
    It should (does in my test) report the value of y each time it iterates the loop

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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