+ Reply to Thread
Results 1 to 3 of 3

If statement UDF with the possibility of multiple true statements (how to fix)?

  1. #1
    Registered User
    Join Date
    03-08-2014
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    22

    If statement UDF with the possibility of multiple true statements (how to fix)?

    An example of the problem is that let's say the fourth statement (If Code4 = Maincode And Class4 < 48 Or Class4 > 54 Then
    Cantdisclose = Class4) is the first statement to satisfy all conditionals. I want excel to return Cantdisclose as Class4. However, Excel continues reading the UDF and returns the last true if statement

    Full Code Below:

    Please Login or Register  to view this content.
    Any way to fix this?

    Thanks
    Last edited by Excel2010101; 03-10-2014 at 01:49 AM.

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: If statement UDF with the possibility of multiple true statements (how to fix)?

    You must use ElseIf:
    Please Login or Register  to view this content.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Registered User
    Join Date
    03-08-2014
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: If statement UDF with the possibility of multiple true statements (how to fix)?

    @Izandol: Thanks! It worked!

    However, I might have a few more bugs that need fixing (I already fixed one...)
    Last edited by Excel2010101; 03-12-2014 at 01:52 AM.

+ 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. Multiple true statements with a return value
    By Cameleon80 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-27-2012, 09:16 AM
  2. IF Statement for copying multiple cells if argument true
    By saeed9313 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-03-2012, 01:44 AM
  3. Replies: 6
    Last Post: 10-13-2011, 06:38 AM
  4. If statement help-multiple statements
    By vargs in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-09-2010, 03:17 PM
  5. Replies: 1
    Last Post: 06-30-2006, 08:35 PM

Tags for this Thread

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