# urgent - nested ifs

#### jubilee101

##### New Member
Hi guys,
i'm under pressure to get this done in next 3 hours ao any help would be appreciated.

lets say I have 4 cells ABCD. The text in A can will either say "Pass" or "Fail" depending on the following:

IF (B,C,D = blank ) then A=“Pass”
If B not blank but C,D are Blank, then A=“Fail”
If B is not blank and C is not blank then A=“Pass”
IF( B,C,D not blank, then A=“fail”)

I've tried doing nest IFs & AND and I just can't get it to work

Last edited:

#### Joe4

Is it enough to just check for the two "Pass" conditions, and assume all other "False" (if not, then that most mean that there are other situations not accounted for, and what should happen in those situations)?
If so, you can simply use:
Code:
``=IF(OR(AND(B1="",C1="",D1=""),AND(B1<>"",C1<>"")),"Pass","Fail")``

#### MoshiM

##### Active Member
Hi guys,
i'm under pressure to get this done in next 3 hours ao any help would be appreciated.

lets say I have 4 cells ABCD. The text in A can will either say "Pass" or "Fail" depending on the following:

IF (B,C,D = blank ) then A=“Pass”
If B not blank but C,D are Blank, then A=“Fail”
If B is not blank and C is not blank then A=“Pass”
IF( B,C,D not blank, then A=“fail”)

I've tried doing nest IFs & AND and I just can't get it to work
This VBA solution should work assuming the columns you are working with are A,B,C and D

Code:
``````Sub Pass_or_Fail()

Dim Hold As Variant, X As Long, RR As Range

With ActiveSheet.UsedRange

Set RR = .Columns(1)

For X = 2 To 4
Set RR = Application.Union(RR, .Columns(X))
Next X

End With

Hold = RR.Value2

For X = 1 To UBound(Hold, 1)

'B                        'C               'D

If Hold(X, 2) = "" And Hold(X, 3) = "" And Hold(X, 4) = "" Then

Hold(X, 1) = "Pass"'A

ElseIf Hold(X, 2) <> "" And Hold(X, 3) = "" And Hold(X, 4) = "" Then

Hold(X, 1) = "Pass" = "Fail"

ElseIf Hold(X, 2) <> "" And Hold(X, 3) <> "" Then

Hold(X, 1) = "Pass"

ElseIf Hold(X, 2) <> "" And Hold(X, 3) <> "" And Hold(X, 4) <> "" Then

Hold(X, 1) = "Fail"

End If

Next X

RR.Columns(1).Value2 = WorksheetFunction.Index(Hold, 0, 1)'update column A

End Sub``````

Last edited:

#### Trixterz

##### New Member
Try this...

Code:
``````if Range("B1:D1").value=empty then Range("A1").value="Pass"
elseif not Range("B1").Value=empty and Range("C1:D1").value=empty then Range("A1").value = "Fail"
elseif not Range("B1,C1").value=empty then Range("A1").value = "Pass"
elseif not Range("B1:D1").value=empty then Range("A1").value = "Fail"
else
end if``````

#### Joe4

You can use VBA if you want to, but it isn't really necessary here.

#### jubilee101

##### New Member
@joe4

Is it enough to just check for the two "Pass" conditions, and assume all other "False" (if not, then that most mean that there are other situations not accounted for, and what should happen in those situations)?
If so, you can simply use:
Code:
``=IF(OR(AND(B1="",C1="",D1=""),AND(B1<>"",C1<>"")),"Pass","Fail")``
This works for the cells when B,C,D blank. however it isn't changing A to "Fail" if b,c, d are not blank?

Last edited:

#### Joe4

This works for the cells when B,C,D blank. however it isn't changing A to "Fail" if b,c, d are not blank?
If B is not blank and C is not blank then A=“Pass”
Listed below is all possibilities. Please fill in the missing result for each one:
Code:
``````[TABLE="width: 256"]
<tbody>[TR]
[TD="class: xl64, width: 64"]A Blank[/TD]
[TD="class: xl64, width: 64"]B Blank[/TD]
[TD="class: xl64, width: 64"]C Blank[/TD]
[TD="class: xl64, width: 64"]Result[/TD]
[/TR]
[TR]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="class: xl63"]Pass[/TD]
[/TR]
[TR]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="class: xl63"][/TD]
[/TR]
[TR]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="class: xl63"][/TD]
[/TR]
[TR]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="class: xl63"][/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="class: xl63"]Fail[/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="class: xl63"][/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="class: xl63"][/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="class: xl63"]Fail[/TD]
[/TR]
</tbody>[/TABLE]``````

#### jubilee101

##### New Member
Joe,
the cells are populated in order from left to right depending on where we are in the process, so for example, we'd never have the 2nd or 3rd line occur where Cell D has an entry but b & C don't:

Code:
``````[TABLE="width: 256"]
<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl63, width: 64"]A Blank[/TD]
[TD="class: xl63, width: 64"]B Blank[/TD]
[TD="class: xl63, width: 64"]C Blank[/TD]
[TD="class: xl63, width: 64"]Result[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 64"]TRUE[/TD]
[TD="class: xl64, width: 64"]TRUE[/TD]
[TD="class: xl64, width: 64"]TRUE[/TD]
[TD="class: xl63, width: 64"]Pass[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 64"]TRUE[/TD]
[TD="class: xl64, width: 64"]TRUE[/TD]
[TD="class: xl64, width: 64"]FALSE[/TD]
[TD="class: xl63, width: 64"]Pass[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 64"]TRUE[/TD]
[TD="class: xl64, width: 64"]FALSE[/TD]
[TD="class: xl64, width: 64"]FALSE[/TD]
[TD="class: xl63, width: 64"]Pass[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 64"]TRUE[/TD]
[TD="class: xl64, width: 64"]FALSE[/TD]
[TD="class: xl64, width: 64"]TRUE[/TD]
[TD="class: xl63, width: 64"]Pass[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 64"]FALSE[/TD]
[TD="class: xl64, width: 64"]FALSE[/TD]
[TD="class: xl64, width: 64"]FALSE[/TD]
[TD="class: xl63, width: 64"]Fail[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 64"]FALSE[/TD]
[TD="class: xl64, width: 64"]FALSE[/TD]
[TD="class: xl64, width: 64"]TRUE[/TD]
[TD="class: xl63, width: 64"]Pass[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 64"]FALSE[/TD]
[TD="class: xl64, width: 64"]TRUE[/TD]
[TD="class: xl64, width: 64"]FALSE[/TD]
[TD="class: xl63, width: 64"]Fail[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 64"]FALSE[/TD]
[TD="class: xl64, width: 64"]TRUE[/TD]
[TD="class: xl64, width: 64"]TRUE[/TD]
[TD="class: xl63, width: 64"]Fail``````
[/TD]
[/TR]
</tbody>[/TABLE]

Listed below is all possibilities. Please fill in the missing result for each one:
Code:
``````[TABLE="width: 256"]
<tbody>[TR]
[TD="class: xl64, width: 64"]A Blank[/TD]
[TD="class: xl64, width: 64"]B Blank[/TD]
[TD="class: xl64, width: 64"]C Blank[/TD]
[TD="class: xl64, width: 64"]Result[/TD]
[/TR]
[TR]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="class: xl63"]Pass[/TD]
[/TR]
[TR]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="class: xl63"][/TD]
[/TR]
[TR]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="class: xl63"][/TD]
[/TR]
[TR]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="class: xl63"][/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="class: xl63"]Fail[/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="class: xl63"][/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="class: xl63"][/TD]
[/TR]
[TR]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="class: xl63"]Fail[/TD]
[/TR]
</tbody>[/TABLE]``````

#### jubilee101

##### New Member
*meant to say you'd never have 2nd, 3rd or 4th line of table happen

Last edited:

#### Joe4

I was off a column in my grid, it is not A, B, C, but rather B, C, D. But I can now see what you are after.
Since there are only two conditions that would return "Fail", let's check for those, and then have anything else return "Pass", i.e.
Code:
``=IF(OR(AND(B1<>"",C1<>"",D1<>""),AND(B1<>"",D1<>"")),"Fail","Pass")``

1,082,300
Messages
5,364,386
Members
400,796
Latest member
vrcdesktop

### This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...