ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Logical Testing (https://www.excelbanter.com/excel-programming/340637-logical-testing.html)

Lance

Logical Testing
 
How do I set up a logical_test formula with three variable options? For
example: I have a formula that returns a true or false answer, if true the
result will be A, If false it will be B. Now I need to enhance the formula
to include a second test that returns C

JE McGimpsey

Logical Testing
 
You don't give enough information - which test should be applied first?

Assume Formula1:

If Formula1 Then
sResult = "A"
Else
If Formula2 Then
sResult = "C"
Else
sResult = "B"
End If
End If

which can be more compactly written:

If Formula1 Then
sResult = "A"
ElseIf Formula2 Then
sResult = "C"
Else
sResult = "B"
End If

or

sResult = IIf(Formula1, "A", IIf(Formula2, "C", "B"))

In article ,
"Lance" wrote:

How do I set up a logical_test formula with three variable options? For
example: I have a formula that returns a true or false answer, if true the
result will be A, If false it will be B. Now I need to enhance the formula
to include a second test that returns C


Lance

Logical Testing
 
JE,

You're absolutely correct, but, your response took that into consideration.
I am a novice at programming. Regarding which test should be performed
first, it didn't really matter, cause if the test resulted in false then the
next test would perform until the result was true. What I didn't tell you is
that the test was going to be performed after a user selected A, B or C from
a drop down box. It appears as though the latter code is closest to what I
needed because I am going to place the code in the formula window of an excel
spreadsheet. As a matter of fact here is the code I came up with and am
going to use. It just took me most of the day to figure the code.
=IF('Master Input Table'!$D$8="VQE","MM24V",IF('Master Input
Table'!$D$8="VQE1","MM24VE",IF('Master Input Table'!$D$8="DS0","MM24NB")))

Tx,

Lance


"JE McGimpsey" wrote:

You don't give enough information - which test should be applied first?

Assume Formula1:

If Formula1 Then
sResult = "A"
Else
If Formula2 Then
sResult = "C"
Else
sResult = "B"
End If
End If

which can be more compactly written:

If Formula1 Then
sResult = "A"
ElseIf Formula2 Then
sResult = "C"
Else
sResult = "B"
End If

or

sResult = IIf(Formula1, "A", IIf(Formula2, "C", "B"))

In article ,
"Lance" wrote:

How do I set up a logical_test formula with three variable options? For
example: I have a formula that returns a true or false answer, if true the
result will be A, If false it will be B. Now I need to enhance the formula
to include a second test that returns C




All times are GMT +1. The time now is 11:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com