# IF Function

#### RJB78

##### Board Regular
Hello. I am trying to get A,B,C,D to appear based on a different cells value

IF U7 is less than 5; then "A"
IF U7 is less greater than 5, but less than 20; "B"
IF U7 is greater than 20; then "C"
IF U7 is "N/A" (from a vlookup); "D"

This is what I have now and it works for the "C" but returns #Value for anything that should return "A" and False for anything that should return "B"

=IF(IF(\$U7<5,"A"),IF(AND(\$U7>5,\$U7<20),"B"),IF(\$U7>20,"C"),IF(\$U7="N/A","D"))

Last edited:

### Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

#### CyrusTheVirus

##### Well-known Member
Try this:

Code:
``=IF(\$U7<5,"A",IF(AND(\$U7>5,\$U7<20),"B",IF(\$U7>20,"C",IF(ISERROR(\$U7),"D"))))``

Last edited:

#### RJB78

##### Board Regular
That works except the last part, "C" appeared instead of "D"

Last edited:

#### CyrusTheVirus

##### Well-known Member
what do you have in U7?

Also, please note that you don't have criteria stating what you want if something is exactly 5 or 20, you only have greater than or less than, not greater than or equal to or less than or equal too. If you want to include 5 and 20, try the below.

Code:
``A=IFERROR(IF(\$U7<5,"A",IF(AND(\$U7>=5,\$U7<=20),"B",IF(\$U7>20,"C"))),"D")``

Last edited:

#### RJB78

##### Board Regular
U7 is a vlookup to a number, the letter is based off the number, but for some lookups there aren't any numbers so it returns N/A, I want it to return D

#### CyrusTheVirus

##### Well-known Member
Does the below formula not work for you? It should.

Code:
``=IFERROR(IF(\$U7<5,"A",IF(AND(\$U7>=5,\$U7<=20),"B",IF(\$U7>20,"C"))),"D")``

Replies
0
Views
281
Replies
4
Views
265
Replies
3
Views
191
Replies
2
Views
178
Replies
5
Views
213

1,191,287
Messages
5,985,754
Members
439,979
Latest member
alekun86

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

### Which adblocker are you using?

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

### Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back