+ Reply to Thread
Results 1 to 7 of 7

multiple if statements

  1. #1
    Forum Contributor
    Join Date
    06-17-2013
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    247

    multiple if statements

    Hi All,

    i am creating some error checking on a template of mine and i need to have a code that runs a bunch of if statements and exits if it doesnt meet the criteria at any step of the process, and the end result if it passes all criteria is 'msgbox go' but i cant seem to get it right - excel 2007


    Please Login or Register  to view this content.

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: multiple if statements

    Hi 13lack13lade, that's a problem due to poor indentations.


    How your chunk of code looks like when properly indented:
    Please Login or Register  to view this content.
    It becomes very visible that you are missing many End If's. I didn't check through your If statements though, I assume they are working as expected.
    多么想要告诉你 我好喜欢你

  3. #3
    Forum Contributor
    Join Date
    06-17-2013
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    247

    Re: multiple if statements

    where do the endif's go because ive tried seperating them all into seperate if statements and also putting all the end ifs at the end and none of which seem to work.

    if i separate them out then it runs but doesnt do anything..

  4. #4
    Forum Contributor
    Join Date
    06-17-2013
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    247

    Re: multiple if statements

    Its fine ive figured it out, i separated them into different subs, then created a new sub to call them all, works fine

    Thanks for your help

  5. #5
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: multiple if statements

    try this
    Please Login or Register  to view this content.

  6. #6
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: multiple if statements

    I personally would avoid heavily nested If-Else statements, so I would do it this way, separating each condition:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    06-17-2013
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    247

    Re: multiple if statements

    Thanks lancer, mine just ran the statements but didnt actually stop the if statements, your code is exactly what i was looking for!

+ 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. [SOLVED] Nested if statements containing multiple and statements
    By John M. in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-22-2014, 11:48 PM
  2. Formula with multiple IF statements and IF AND statements
    By lottidotti in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-14-2013, 08:03 AM
  3. Replies: 3
    Last Post: 07-25-2013, 08:25 AM
  4. Multiple nested IF statements and AND statements
    By TonyGetz in forum Excel General
    Replies: 2
    Last Post: 12-14-2010, 03:07 AM
  5. Replies: 12
    Last Post: 05-15-2009, 08:38 AM

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