=IF(AND... function

M

Mukesh

I need 2 conditions to meet else it should be an empty sell.
My code is
=IF(AND(K47="abc", B3>=I49), (H49-B3)*J49*1000, (H49-I49)*J49*1000)

I still get the calculated value, even if cell K47 is blank.

Please help.

Thanks.
Mukesh
 
T

T. Valko

I need 2 conditions to meet else it should be an empty sell.
=IF(AND(K47="abc", B3>=I49), (H49-B3)*J49*1000, (H49-I49)*J49*1000)
I still get the calculated value, even if cell K47 is blank.

If K47 is blank then AND = FALSE and the IF function evaluates the
value_if_false argument which is:

(H49-I49)*J49*1000

So, if both conditions are not met and you want the cell left blank then:

=IF(AND(K47="abc", B3>=I49), (H49-B3)*J49*1000,"")
 
M

Mukesh

=IF(AND(K47="abc", B3>=I49), (H49-B3)*J49*1000,""),
I do get a blank cell, but it doesn't calculate if B3<=I49.

I am not able to put code right.
IF K47="abc" && (B3>=I49), (H49-B3)*J49*1000, " " OR
IF K47="abc" && (B3<=I49), (H49-I49)*J49*1000, " "

Please advise.

Thanks.
Mukesh
 
T

T. Valko

IF K47="abc" && (B3>=I49), (H49-B3)*J49*1000, " " OR
IF K47="abc" && (B3<=I49), (H49-I49)*J49*1000, " "

Ok, but you have a logic conflict:

If B3 does = I49 what should the result be? According to the above it should
be both:

(H49-B3)*J49*1000
(H49-I49)*J49*1000

I'll assume the logic should be >=I49 for (H49-B3)*J49*1000
and <I49 for(H49-I49)*J49*1000

=IF(K47="abc",IF(B3>=I49,(H49-B3)*J49*1000,(H49-I49)*J49*1000),"")

That doesn't account for empty cells!
 
M

Mukesh

That worked! thanks a lot.

Mukesh



T. Valko said:
Ok, but you have a logic conflict:

If B3 does = I49 what should the result be? According to the above it should
be both:

(H49-B3)*J49*1000
(H49-I49)*J49*1000

I'll assume the logic should be >=I49 for (H49-B3)*J49*1000
and <I49 for(H49-I49)*J49*1000

=IF(K47="abc",IF(B3>=I49,(H49-B3)*J49*1000,(H49-I49)*J49*1000),"")

That doesn't account for empty cells!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top