ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   conditions in Excel (https://www.excelbanter.com/excel-programming/307042-conditions-excel.html)

farsta_online

conditions in Excel
 
Hi,
I need help with conditions:

How do I write the content of cell B9:
1)A20 AND B20
if true: B9 = c
if False: B9 = d

2) A20 or B20
if true: B9 = e
if False: B9 = f

3) A2 = g AND B2 = h AND C2 = i
if true: B9 = j
if False: B9 = k

4) A2 = l OR B2 = m OR C2 = n
if true: B9 = o
if False: B9 = p

Any answer willbe appriceated
Peter

Frank Kabel

conditions in Excel
 
Hi
some questions:
- do you want a worksheet formula or a VBA solution?
- your first and second condition are identical but you want different
results?

--
Regards
Frank Kabel
Frankfurt, Germany


farsta_online wrote:
Hi,
I need help with conditions:

How do I write the content of cell B9:
1)A20 AND B20
if true: B9 = c
if False: B9 = d

2) A20 or B20
if true: B9 = e
if False: B9 = f

3) A2 = g AND B2 = h AND C2 = i
if true: B9 = j
if False: B9 = k

4) A2 = l OR B2 = m OR C2 = n
if true: B9 = o
if False: B9 = p

Any answer willbe appriceated
Peter



Peter L

conditions in Excel
 
Hi Frank and thanks for your answer
If it not too mutch trubble I would like to have both a worksheet
formula or a VBA solution?

In your answer you wrote that:"your first and second condition are
identical but you want different
results?" They arenīt identical, in #1 both conditions have to been met
and in #2 either of the conditionx

Regards
Peter




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Frank Kabel

conditions in Excel
 
Hi
sorry for not reading carefully enough (too early in the morning).
Though there's still a problem:
Assume the first condition is not met (e.g. only A20) then you say you
want the 'False' result of 'd'. BUT your second condition in this case
is also met and this would require 'e'. So what is for example your
expected result for:
A2 = 2
B2 = -1



--
Regards
Frank Kabel
Frankfurt, Germany


Peter L wrote:
Hi Frank and thanks for your answer
If it not too mutch trubble I would like to have both a worksheet
formula or a VBA solution?

In your answer you wrote that:"your first and second condition are
identical but you want different
results?" They arenīt identical, in #1 both conditions have to been
met and in #2 either of the conditionx

Regards
Peter




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Peter L

conditions in Excel
 


Oki, I see how you mean. But Iīm looking for the principle to write
multiple conditions
/Peter

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Peter L

conditions in Excel
 
OK, itīs maybee easier if I give a real life example:
D8 = 100 AND 1.5 < D6/D8 < 25
IF True: D8 = 100
else D8 = 250 AND 1.5 < D6/D8 < 25
If True: D8 = 250
else
D8 = 500 AND 1.5 < D6/D8 < 25
If TrueD8 = 500

Do you see what Iīm trying to do?
/Peter




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Frank Kabel

conditions in Excel
 
Hi
you could always used nested IF conditions. To give you an example
=IF(AND(A10,B10),"A1+B1 0",IF(OR(A10,B10),"A1 or B1 are 0","None
is greater than zero"))

Note: The maximum are 7 nested function calls


--
Regards
Frank Kabel
Frankfurt, Germany


Peter L wrote:
Oki, I see how you mean. But Iīm looking for the principle to write
multiple conditions
/Peter

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



NickHK

conditions in Excel
 
Peter,
D8 cannot hold a value and also the result of a comparison. It's one or the
other. You logic is not sensible as you wish to change the value that you
are using in the comparison to what it would have to be true anyway.

In terms of multiple condition, something this formula in D9 may be what you
want:
=IF(AND(D6/D81.5,D6/D8<25),D8,FALSE)

NickHK

"Peter L" wrote in message
...
OK, itīs maybee easier if I give a real life example:
D8 = 100 AND 1.5 < D6/D8 < 25
IF True: D8 = 100
else D8 = 250 AND 1.5 < D6/D8 < 25
If True: D8 = 250
else
D8 = 500 AND 1.5 < D6/D8 < 25
If TrueD8 = 500

Do you see what Iīm trying to do?
/Peter




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 03:12 PM.

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