+ Reply to Thread
Results 1 to 5 of 5

Need help with For... loop that has a nested if statement

  1. #1
    Registered User
    Join Date
    05-21-2009
    Location
    Austin, TX
    MS-Off Ver
    Office 2010
    Posts
    10

    Need help with For... loop that has a nested if statement

    hi all,

    I know I'm going to slap myself when I get the answer to this because I'm sure it's staring right at me.

    Anyways, I've got an input box that the user has to enter two numbers, and I want to check whether the number is an even number. If its an odd number, I want to move to the next number.

    Here's the sample code of what i'm trying to do...

    Please Login or Register  to view this content.
    I've tried "goto next i" but I get a syntax error.

    Thanks in advance


    Edit ; Sorry looks like I posted in the worng sub forum. if that's the case can a mod move the thread please
    Last edited by iLurk; 09-24-2009 at 06:58 PM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Need help with For... loop that has a nested if statement

    I'm not good at VBA, but according to simple programming logic, could it be

    Please Login or Register  to view this content.
    ?

  3. #3
    Registered User
    Join Date
    05-21-2009
    Location
    Austin, TX
    MS-Off Ver
    Office 2010
    Posts
    10

    Re: Need help with For... loop that has a nested if statement

    Quote Originally Posted by teylyn View Post
    I'm not good at VBA, but according to simple programming logic, could it be

    Please Login or Register  to view this content.
    ?
    Thanks but nope that won't work because you'll get a "next without for.." error.

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

    Re: Need help with For... loop that has a nested if statement

    Pretty hard to guess what you're trying to do.
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    05-21-2009
    Location
    Austin, TX
    MS-Off Ver
    Office 2010
    Posts
    10

    Re: Need help with For... loop that has a nested if statement

    Thanks shg,

    My macro is made so that it runs for different processes for odd numbers and even numbers.

    but I fugured it out by doing putting a reverse if statement around my even number code. D'oh!

    Please Login or Register  to view this content.
    Like I said, I knew the answer was staring tight at me. Spent damn near 12 hours straight coding yesterday and I guess my brain had just had enough Amazing what few hours of sleep can do.


    Thanks to both of you for your suggestions though.
    Last edited by iLurk; 09-24-2009 at 06:59 PM.

+ 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