Results 1 to 8 of 8

Conditional Statements & Nested If/Then in VBA

Threaded View

  1. #1
    Registered User
    Join Date
    02-09-2018
    Location
    US
    MS-Off Ver
    2016
    Posts
    5

    Unhappy Conditional Statements & Nested If/Then in VBA

    I am trying to write a function or sub which passes in 3 variables from the worksheet and returns a number 0-3 based on conditional statements (nested If/then). However, the func returns ‘0’ for all cases. Using breaks in the module, I can see this is because, while the variables have been passed in (UpIso, Con, DIso), the function (isolation) =’empty’

    My code is below. Any help is appreciated. Thanks

    Function Isolation(UpIso, Con, DIso) As Variant
    
    ‘Free discharge
    If (UpIso = Y And Con = FD And (DIso = Y Or DIso = NA)) Then
    Isolation = 0
    
    ElseIf (UpIso = N And Con = FD And (DIso = Y Or DIso = NA)) Then
    Isolation = 3
    
    ‘Back Pressure
    ElseIf (UpIso = Y And Con = BP And DIso = Y) Then
    Isolation = 0
    
    ElseIf (UpIso = Y And Con = BP And DIso = N) Then
    Isolation = 2
    
    ElseIf (UpIso = Station And Con = BP And DIso = Y) Then
    Isolation = 1
    
    ElseIf (UpIso = Station And Con = BP And DIso = N) Then
    Isolation = 2
    
    ElseIf (UpIso = N And Con = BP And DIso = Y) Then
    Isolation = 2
    
    ElseIf (UpIso = N And Con = BP And DIso = N) Then
    Isolation = 3
    
    End If
    
    End Function
    Last edited by 6StringJazzer; 02-09-2018 at 10:46 AM. Reason: added CODE tags

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. 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 with AND and OR statements
    By joeljoel in forum Excel General
    Replies: 4
    Last Post: 08-08-2011, 12:57 PM
  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. Nested If statements / logic statements
    By Brainless_09 in forum Excel General
    Replies: 3
    Last Post: 06-17-2009, 02:59 PM
  6. Replies: 12
    Last Post: 05-15-2009, 08:38 AM
  7. Nested conditional statements
    By Apel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2006, 01:28 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