# Help with True/False Formula

#### McNeil87

##### New Member
Hello!

Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True, IF(AH2=TRUE,TRUE,FALSE),TRUE). The result brings True, but it actually needs to be False (for this specific case). Am I missing a 'False' statement after the first logical test? Any recommendations how I should write this would be great. All the data returns True, and that is not correct.

Thank you!

#### Attachments

• 33.2 KB Views: 8

#### Michael M

##### Well-known Member
Maybe this

VBA Code:
``=IF(AND(AG2=TRUE, AH2=TRUE),TRUE,FALSE)``

#### McNeil87

##### New Member
Thank you. Can you explain what break this down? Does this mean, IF AG2=True, and AH2=True, then return 'True', Else ' false'? The ANd statement returns will return true if both criteria are true, correct?

#### Michael M

##### Well-known Member
Yes, you are correct.
If either / neither are TRUE then it will return FALSE

#### 6StringJazzer

##### Active Member
I think you are all tangled up with Boolean logic. You are saying what your formula should return, but you do not tell us the values for AG or AH, or why you think this formula should return FALSE.

First of all let's look at this expression within your formula:
`AG=TRUE`
So AG must be TRUE or FALSE. If it is TRUE, you want the result of this comparison to be TRUE. That is exactly the same as just
`AG`

Similarly,
`IF(AH=TRUE,TRUE,FALSE)`
gives the same result as just
`AH`

`=IF(AG2=TRUE,IF(AH=TRUE,TRUE,FALSE),TRUE)`

This is logically equivalent to
`=IF(AG,AH,TRUE)`

Now. What are the values of AG and AH? If your formula is giving you a different result than you expect, please explain the logic you want to use.

Here is the truth table for your formula:

 AG AH RESULT TRUE TRUE TRUE TRUE FALSE FALSE FALSE TRUE TRUE FALSE FALSE TRUE

#### sandy666

##### Well-known Member
BCDEF
2
3AND
4TrueTrue
5FalseFalse
6TrueFalse
7FalseTrue
8
9
Cell Formulas
Range(s)Formula
E4:E7E4=AND(C4,D4)

#### McNeil87

##### New Member
Cell AG is a contract , and AH is a program.. So, IF Cell AG is a contract and part of a program, then return True. If Cell AG (contract) is a contract, BUT not part of a program, then return 'False.' IF AG is not a contract, and is not part of a program, return False.

#### McNeil87

##### New Member
I think you are all tangled up with Boolean logic. You are saying what your formula should return, but you do not tell us the values for AG or AH, or why you think this formula should return FALSE.

First of all let's look at this expression within your formula:
`AG=TRUE`
So AG must be TRUE or FALSE. If it is TRUE, you want the result of this comparison to be TRUE. That is exactly the same as just
`AG`

Similarly,
`IF(AH=TRUE,TRUE,FALSE)`
gives the same result as just
`AH`

`=IF(AG2=TRUE,IF(AH=TRUE,TRUE,FALSE),TRUE)`

This is logically equivalent to
`=IF(AG,AH,TRUE)`

Now. What are the values of AG and AH? If your formula is giving you a different result than you expect, please explain the logic you want to use.

Here is the truth table for your formula:

 AG AH RESULT TRUE TRUE TRUE TRUE FALSE FALSE FALSE TRUE TRUE FALSE FALSE TRUE

Cell AG is a contract , and AH is a program.. So, IF Cell AG is a contract and part of a program, then return True. If Cell AG (contract) is a contract, BUT not part of a program, then return 'False.' IF AG is not a contract, and is not part of a program, return False.

#### McNeil87

##### New Member
Yes, you are correct.
If either / neither are TRUE then it will return FALSE
Thank you

#### McNeil87

##### New Member
Cell AG is a contract , and AH is a program.. So, IF Cell AG is a contract and part of a program, then return True. If Cell AG (contract) is a contract, BUT not part of a program, then return 'False.'
I think you are all tangled up with Boolean logic. You are saying what your formula should return, but you do not tell us the values for AG or AH, or why you think this formula should return FALSE.

First of all let's look at this expression within your formula:
`AG=TRUE`
So AG must be TRUE or FALSE. If it is TRUE, you want the result of this comparison to be TRUE. That is exactly the same as just
`AG`

Similarly,
`IF(AH=TRUE,TRUE,FALSE)`
gives the same result as just
`AH`

`=IF(AG2=TRUE,IF(AH=TRUE,TRUE,FALSE),TRUE)`

This is logically equivalent to
`=IF(AG,AH,TRUE)`

Now. What are the values of AG and AH? If your formula is giving you a different result than you expect, please explain the logic you want to use.

Here is the truth table for your formula:

 AG AH RESULT TRUE TRUE TRUE TRUE FALSE FALSE FALSE TRUE TRUE FALSE FALSE TRUE

IF AG is not a contract, and is not part of a program, return False.
Looking at your table further, your table is correct. I have both cells as a 'False' Statements, and the result needs to return true.

I am stumped.

1,081,856
Messages
5,361,718
Members
400,650
Latest member
tcisrly

### 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...