kf7ebx
kf7ebx

Reputation: 1

What is wrong with my formula

I have been working on an EXCEL formula and am stuck.

=If(B10<4, B10*0, If(B10>3 AND B10<8, B10*1, B10*2)))

I keep getting an error. Can someone tell me what is wrong with it.

What I am trying to do is say:

Upvotes: 0

Views: 60

Answers (3)

Slai
Slai

Reputation: 22876

Can be shortened to =B10*((B10>=4)+(B10>=8))

Upvotes: 1

Ben Jackson
Ben Jackson

Reputation: 23

Looks like you have one too many parentheses. should look something like

=If(B10<4, B10*0, If(AND(B10>3, B10<8), B10, B10*2)))

This formula takes the and statement and places it inside of the second If statement, checking to see if the cell B10 is greater than or equal to 4 and then checking to see if the cell B10 is both less than 8 or greater than 3.

Upvotes: 1

Scott Craner
Scott Craner

Reputation: 152450

AND, is AND(condition1,Conditon2) not condition1 AND Condtion2

=If(B10<4, B10*0, If(AND(B10>3, B10<8), B10*1, B10*2))

That being said you do not need the AND at all:

=If(B10<4, B10*0, If(B10<8, B10*1, B10*2)))

The second if will fire only if B10 >= 4 so the B10>3 is not needed.


And since anything multiplied by 0 is 0 you do not need the B10*0. And since anything multiplie by 1 is itself, you do not need the *1

=If(B10<4, 0, If(B10<8, B10, B10*2)))
  • Credit @BruceWayne.

Upvotes: 3

Related Questions