+ Reply to Thread
Results 1 to 4 of 4

If-Else just stops

  1. #1
    Registered User
    Join Date
    05-15-2007
    Posts
    17

    If-Else just stops

    Greetings,

    I have the following field-validating VBscript in an Excel spreadsheet:

    Please Login or Register  to view this content.
    When cell K3 = 1, the script checks other cells in the inner IF statement, and puts up MsgBoxes if certain conditions are true. This much works fine.

    The problem is: if all of the conditions in the inner IF statement are false (i.e. all the cells have what they're supposed to have in them, and no MsgBoxes have to be put up) the outer IF statement just STOPS. The next part of it:

    Please Login or Register  to view this content.
    is not executed. It's as though VBscript thinks the "End If" in the inner IF statment is part of the outer If statement (??).

    Now, when cell K3 is not equal to 1, the entire outer IF statement is executed. So the problem is with the inner IF statment.

    Any idea what the problem is?

    Thanks!
    DM
    Office 2001 Mac version

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    Perhaps a solution is to use more 'If ... End If' statements and not 'If... Elseif... End If'.

    This may be an idea (also if it's not elegant to read):
    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    05-15-2007
    Posts
    17
    Hi Antonio,

    I thought about that very thing after I posted, and tried it. But the problem is, I want to stop after the first MsgBox. Give the user a chance to go back and fill in that one cell. By making separate IF statements. It fires off one MsgBox after another.

    Or is there a way to EXIT a function? Like the "return" statement in Perl, for example.

    Thanks much for your reply,
    DM

  4. #4
    Registered User
    Join Date
    05-15-2007
    Posts
    17
    D'oh! I found it. "Exit Function"

    Who would have guessed?

    DM

+ 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