+ Reply to Thread
Results 1 to 3 of 3

IF, AND & OR Syntax Issues

  1. #1
    Forum Contributor
    Join Date
    06-23-2010
    Location
    Iowa, United States
    MS-Off Ver
    Excel 2007
    Posts
    145

    IF, AND & OR Syntax Issues

    Hello,

    I am attempting to use a series of AND & OR commands within an IF statement. I believe the issue lies within the PaymentMonth = StartMonth portion of the code below:

    Please Login or Register  to view this content.
    The PaymentMonth variable is an integer representing the current month. The StartMonth is an integer representing the month of payment. The code seems to be registering every month as true. I believe it has something to do with the syntax of my OR statements. Does anyone have any ideas? Thanks for your time.

    Steve
    A VBA novice, excited to learn!

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: IF, AND & OR Syntax Issues

    Looks like you might be failing to test the full expression in each OR. Maybe use a boolean variable to simplify it a bit?

    Please Login or Register  to view this content.
    Last edited by AlvaroSiza; 06-18-2013 at 12:01 AM. Reason: PUI
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  3. #3
    Forum Contributor
    Join Date
    06-23-2010
    Location
    Iowa, United States
    MS-Off Ver
    Excel 2007
    Posts
    145

    Re: IF, AND & OR Syntax Issues

    Perfect. Thank you!

    Steve

+ 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