IF Function

RJB78

Board Regular
Joined
Aug 8, 2016
Messages
54
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:

CyrusTheVirus

Well-known Member
Joined
Jan 28, 2015
Messages
736
Office Version
365
Platform
Windows
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
Joined
Aug 8, 2016
Messages
54
That works except the last part, "C" appeared instead of "D"
 
Last edited:

CyrusTheVirus

Well-known Member
Joined
Jan 28, 2015
Messages
736
Office Version
365
Platform
Windows
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
Joined
Aug 8, 2016
Messages
54
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
Joined
Jan 28, 2015
Messages
736
Office Version
365
Platform
Windows
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")
 

Forum statistics

Threads
1,082,258
Messages
5,364,090
Members
400,779
Latest member
lumers

Some videos you may like

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...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top