+ Reply to Thread
Results 1 to 8 of 8

lines in loop don't execute when program is run

  1. #1
    Registered User
    Join Date
    08-08-2012
    Location
    Chicago IL
    MS-Off Ver
    Excel 2010
    Posts
    15

    lines in loop don't execute when program is run

    Hello,

    I am working a program that is supposed to take a value the user inputs, search a database for it, and within all the entries that have that value, find another user input quality. I'm having trouble with my second loop. The code is below:
    Please Login or Register  to view this content.
    I'm not getting any compile or runtime errors, but while stepping through the program, I found that the program will correctly execute this line:
    Please Login or Register  to view this content.
    which is inside the first loop and outside of the second loop, but not this line of code:
    Please Login or Register  to view this content.
    and will therefore not perform any of the if statements after this line. After it executes the "For Row =" line, it goes directly to "if yes = false"

    Any ideas why this could be happening?

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: lines in loop don't execute when program is run

    Row is a Excel reserve keyword. Try changing all references to iRow.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    08-08-2012
    Location
    Chicago IL
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: lines in loop don't execute when program is run

    Thanks David, I made that change, but it is still skipping from the start of the loop to the if statement after it. Anything else I may not have thought of?

  4. #4
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: lines in loop don't execute when program is run

    Where is NumInFam initialized? (Or what is it?)

    Setup Quick watch on several variables in the loop and see what value they get assigned.

  5. #5
    Registered User
    Join Date
    08-08-2012
    Location
    Chicago IL
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: lines in loop don't execute when program is run

    Quote Originally Posted by Tinbendr View Post
    Where is NumInFam initialized? (Or what is it?)

    Setup Quick watch on several variables in the loop and see what value they get assigned.
    NumInFam is initialized at the top of the module and it is a public variable. Here is the code:
    Please Login or Register  to view this content.
    Also, I've been watching the variables as I step through the program, and EngSizeEnter gets assigned the right value and dbEngSize doesn't even get assigned.

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

    Re: lines in loop don't execute when program is run

    what is the value of NumInFam when you run the code? if it's 0 then the inner loop won't run at all.
    Josie

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

  7. #7
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: lines in loop don't execute when program is run

    In the Sub FindRowToInsert, and just before For Row = i To (i + (NumInFam - 1)), add

    Please Login or Register  to view this content.
    and see what it is returning. If it's less than 1, then that is your problem.

  8. #8
    Registered User
    Join Date
    08-08-2012
    Location
    Chicago IL
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: lines in loop don't execute when program is run

    Tinbendr, Thank you so much for this useful tool!!! and JosephP, yes it's returning zero, so I guess I'll have to figure that one out. Thanks so much for your help!

+ 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