+ Reply to Thread
Results 1 to 6 of 6

Replacing too many logical statements in IF-ELSE Condition

  1. #1
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Manila, Philippines
    MS-Off Ver
    2019
    Posts
    102

    Replacing too many logical statements in IF-ELSE Condition

    Hello Excel gurus!

    As the title suggests, is there a way on how I can compress lines and lines of logical/conditional statements in an IF-ELSE statement? I have been searching for an applicable and most effective approach but they offer solutions a bit far from what I want to achieve.

    For example.
    I want to check if multiple Textboxes in a userform hold values or simply empty, and then execute some action.

    Please Login or Register  to view this content.
    I am using the For...Next looping statement in some of part the program, but am not able to apply it in this instance.

    Below is the sample of my code with looping statement.
    Please Login or Register  to view this content.
    Hope you can give me a shorter way to do this.

    Thanks in advance.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Replacing too many logical statements in IF-ELSE Condition

    What are you actually checking the textboxes for?

    Also, do you need to check them all at the same time?

    If you want to validate input wouldn't it be better to do them one at a time?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Manila, Philippines
    MS-Off Ver
    2019
    Posts
    102

    Re: Replacing too many logical statements in IF-ELSE Condition

    In a userform, there are multiple textboxes for user input, and a command button needs to check if all textboxes are filled out before say, going to the next userform. All of the textboxes need to be checked all at the same time, so that proceeding to the next userform will be stopped in case one of them holds no value (or empty).

    To answer your question Norie, the textboxes need to be checked if one of them is empty.

    Thanks.

  4. #4
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Manila, Philippines
    MS-Off Ver
    2019
    Posts
    102

    Re: Replacing too many logical statements in IF-ELSE Condition

    double post
    Last edited by ykobure; 08-26-2015 at 07:30 AM. Reason: double post

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Replacing too many logical statements in IF-ELSE Condition

    Why not check them one at a time?

    If one of them doesn't have valid input, tell the user, return focus to the offending textbox and exit the sub.
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Manila, Philippines
    MS-Off Ver
    2019
    Posts
    102

    Re: Replacing too many logical statements in IF-ELSE Condition

    I knew there is a better way to do this! Thanks a lot Norie!

+ 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. Combining Multiple if statements using logical operators
    By arahant16 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-24-2014, 03:49 AM
  2. logical statements and minimum values
    By fpalmay in forum Excel General
    Replies: 1
    Last Post: 04-20-2009, 12:30 PM
  3. If Statement Logical Statements
    By klinrya in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-14-2007, 03:31 PM
  4. logical condition
    By federfico in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-14-2007, 11:47 AM
  5. 3 logical condition if statement
    By Mikehughes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-19-2006, 08:59 AM
  6. Intervals as logical statements
    By xnadeau in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-25-2005, 04:05 PM
  7. Logical ELSE statements
    By Ruth in forum Excel General
    Replies: 2
    Last Post: 06-23-2005, 11:05 AM
  8. [SOLVED] Logical Function - Multiple IF statements
    By vnsrod2000 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-04-2005, 08:06 PM

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