# Too many arguments to function in "if" function

#### Kwnstantinos_M

##### New Member
Hello

I wrote a formula in order to trace the boundaries of some wind values. The boundaries are 0-90 / 91-180 / 181-270 / 271-360, and in return I want to get 0 for the first group, 1,2,3 for the second,third and fourth respectively. The formula is the next one:

=if(R2<=90;0;;if(and(R2>=91;R2<=180);1;;if(and(R2>=181;R2<=270);3;;if(and(R2>=271;R2<=360);4; The outcome is "too many arguments" . What do you think it's wrong?

(e.g. I use ; instead of , because my data had comma and there would be a problem with the calculations)

#### dave2018

##### Board Regular
THis works for me:

=IF(R2<=90,0,IF(AND(R2>=91,R2<=180),1,IF(AND(R2>=181,R2<=270),3,IF(AND(R2>=271,R2<=360),4))))

still not sure why u use ; instead of ,

___________________

edit: btw, if u have excel 2016, u can use this shortened version:

=IFS(R2<91,0,R2<181,1,R2<271,2,R2<=360,3)

Last edited:
• Kwnstantinos_M

##### Well-known Member
Hi,

Another way :

=LOOKUP(R2,{0,91,181,271},{0,1,2,3})

• dave2018

#### Kwnstantinos_M

##### New Member
Thank you very much... the problem obviously was that I was using 2 ";" instead of 1, after the if.. Thank you, it works!

#### jtakw

##### Well-known Member
Hi,

Personally, I'd go with the LOOKUP as suggested by admiral100, but here's a shortened version of the IF formula, you Don't need any of the AND statements:

=IF(R2<=90,0,IF(R2<=180,1,IF(R2<=270,3,IF(R2<=360,4))))

• Kwnstantinos_M

#### Kwnstantinos_M

##### New Member
Thank you... yes it works too, and it's more simple. #### dave2018

##### Board Regular
Hi,

Another way :

=LOOKUP(R2,{0,91,181,271},{0,1,2,3})
that is the most correct way • Kwnstantinos_M

#### jtakw

##### Well-known Member
Thank you... yes it works too, and it's more simple. You're welcome, welcome to the forum.

• Kwnstantinos_M

1,081,929
Messages
5,362,182
Members
400,671
Latest member
Tommy00836

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