+ Reply to Thread
Results 1 to 5 of 5

If statements

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    If statements

    Hi.
    I posted a problem i thought i had earlier today about multiple if statements and it turned out that there was no issue but rather something else in the code was messing up the if statements.
    However, i just ran into a different issue and am hoping someone can help me out on it. I reviewed it many times and looked for any portions of the code that might cause a bug but so far everything seems in its place but it's still not executing properly.
    If IsEmpty(Range("E3")) And IsEmpty(Range("F8")) And IsEmpty(Range("F10")) And IsEmpty(Range("F14")) Then
    MsgBox "No customers found!"
    Exit Sub
    If IsEmpty(Range("E3")) And Not IsEmpty(Range("F8")) Or Not IsEmpty(Range("F10")) Or Not IsEmpty(Range("F14")) Then
    MsgBox "You forgot to enter name for customer as seen on the ""Orders Chart""!"
    Exit Sub
    End If
    End If
    
    'IF E3 IS NOT EMPTY THEN THE REST OF THE CODE (which i omitted as it's not important) SHOULD EXECUTE
    If Not IsEmpty(Range("E3") Then
    '
    '
    '
    '
    '
    '
    I am trying to have the rest of the code (which i did not post) to execute if E3 is NOT EMPTY.
    Any ideas?

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If statements

    First thing I notice, not sure if it is a typo though.

    If Not IsEmpty(Range("E3") Then
    should be:

    If Not IsEmpty(Range("E3")) Then
    Line under commented line.

  3. #3
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: If statements

    Agreed, was typo and still not working.

  4. #4
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: If statements

    Hi.
    I rearranged the statements and it wroks perfectly now!
    If IsEmpty(Range("E3")) Then
    If IsEmpty(Range("F8")) And IsEmpty(Range("F10")) And IsEmpty(Range("F14")) Then
    MsgBox "No customers found!"
    Exit Sub
    End If
    If Not IsEmpty(Range("F8")) Or Not IsEmpty(Range("F10")) Or Not IsEmpty(Range("F14")) Then
    MsgBox "You forgot to enter name for customer as seen on the ""Orders Chart""!"
    Exit Sub
    End If
    End If

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If statements

    Glad to hear that. Sometimes trial and error will provide the solution.

+ 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. Reading If statements and formulating values from if statements
    By crnam in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-16-2013, 05:20 AM
  2. questions with if statements and nested if statements
    By Pat Excel in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 02-03-2013, 01:41 PM
  3. Nested If statements / logic statements
    By Brainless_09 in forum Excel General
    Replies: 3
    Last Post: 06-17-2009, 02:59 PM
  4. Replies: 12
    Last Post: 05-15-2009, 08:38 AM
  5. operator statements, shorting when reusing one of the statements?
    By KR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2005, 02:05 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