Use of multiple IF conditions in Excel - excel

I'm trying to get a cell to pick a cell of data from a table using IF (Excel 2010, can't do IFS), but when I try to nest more than 2 IF, it returns a "too many arguments" error. Formula at this point:
=IF(B11="Humain",VLOOKUP(COO,Fonctions!A88:M110,2,FALSE),IF(OR(B11="Hybride Naturel",B11="Géno-Hybride"),VLOOKUP(COO,Fonctions!A88:M110,3,FALSE)))
Where am I doing it wrong? :/

You're missing a final comma should the second IF condition return false. Update your formula like so:
=IF(B11="Humain",VLOOKUP(COO,Fonctions!A88:M110,2,FALSE),IF(OR(B11="Hybride Naturel",B11="Géno-Hybride"),VLOOKUP(COO,Fonctions!A88:M110,3,FALSE),"N/A"))
Notice the N/A that will be produced should both IF statements do not yield any results.

Related

Double nested IF statement formula in Excel

Good morning,
I would like to set a multiple if statement in Excel.
In row 8 you can see the following formula, which gives an answer in column Q. The answer based on this nested formula is Yes or No.
In row 13 all the cells are empty. Because the nested formula has been dragged down it still shows "No".
I was trying to write some double nested IF statement for this, which could cover the situation when the cells are empty and the Q column can come empty as well as a result.
=IF(OR(M9=" ",OR(N9=" ",OR(O9=" ",OR(P9=" "(IF(OR(M9="No", OR(N9="No", OR(O9="No",OR(P9="No")))))),"Yes","No")," ")
Unfortunately, the formula is not working.
Is it a possibility to add up an additional condition for the nested IF statement in Excel?
Something like:
=IF(COUNTA(M2:P2),<YourFormula>,"")
Where <YourFormula> is a placeholder for whatever formula you are interested in when any value in M2:P2 has a value.
As #JvdV has noted in comment above, your latest formula in comment above is still checking for a space, not a null (empty) cell.
Writing " " will look for a cell that contains a space (someone has hit spacebar). Writing "" will check to see if a cell contains nothing, in other words check to see it is empty.
I also noticed the error in your re-write: You wrapped the logical test within the parenthesis for the COUNTA formula. This is your formula corrected:
=IF(COUNTA(M9:P9)=0,(OR(M9="No",OR(N9="No",OR(O9="No",OR(P9="No"))))),"")
However, each OR statement gives a TRUE or FALSE result and can handle multiple arguments, as indicated by #SolarMike so I think you could probably re-write your formula to as follows to get the same result, if I have understood your requirements correctly:
=IF(COUNTA(M9:P9)=0,IF(COUNTIF(M9:P9,"No")>0,"Yes","No"),"")

How Do I use vlookup to search multiple sheets

I am trying to populate a Case # on my contact sheet. The problem is there are three sheets the case # could be on. I have tried the formula
=IFERROR(VLOOKUP($d2,'Jane Tracker'!$A$3:$O$33,4,FALSE),
IFERROR(VLOOKUP($d2,'John Tracker'!$A$3:$O$33,4,FALSE),
IFERROR(VLOOKUP($d2,'Bugs Tracker'!$A$3:$O$33,4,FALSE))))
But I get a "too few arguments" error.
Drop the final IFERROR()
=IFERROR(VLOOKUP($d2,'Jane Tracker'!$A$3:$O$33,4,FALSE),IFERROR(VLOOKUP($d2,'John Tracker'!$A$3:$O$33,4,FALSE),VLOOKUP($d2,'Bugs Tracker'!$A$3:$O$33,4,FALSE)))
It's expecting another value and you just ended the formula.

Multiple if search statements in excel?

I am trying to convert text of the month to the number
B2 cell:
BirthMonth_Jan
BirthMonth_Feb
BirthMonth_mar
BirthMonth_Apr
BirthMonth_May
BirthMonth_Jun, ect to december
for example, BirthMonth_Jan will output 1 based on the search of Jan, so i can compare this to another set of numbers
I have this, and tried this, but only works with two if statements, is there anyway i can do this with 12?
=(IF(ISNUMBER(SEARCH("sep",B2)),"9")),(IF(ISNUMBER(SEARCH("aug",B2)),"8")),(IF(ISNUMBER(SEARCH("jul",B2)),"7")),(IF(ISNUMBER(SEARCH("jun",B2)),"6")),(IF(ISNUMBER(SEARCH("may",B2)),"5")),(IF(ISNUMBER(SEARCH("apr",B2)),"4")),(IF(ISNUMBER(SEARCH("mar",B2)),"3")),(IF(ISNUMBER(SEARCH("feb",B2)),"2")),(IF(ISNUMBER(SEARCH("jan",B2)),"1"))
I get #Value!
If i try this, it also doesn't work
=IF(ISNUMBER(SEARCH("dec",B2)),"12",IF(ISNUMBER(SEARCH("nov",B2)),"11")),IF(ISNUMBER(SEARCH("DSH_KnowBe4_BirthMonth_Oc",B2)),"10"))
the second option only works with two but if i add more it throws an error
The questioner is trying to obtain a numeral equivalent to a partial month name extracted from a string. There are any number of examples in stackoverflow and the net generally on this theme. What is special in this case is the partial month name in the target cell, and use of the IF statement. The questioner is right to use search since it is not case-sensitive
Two formula are offered:
Formula 1
=(IF(ISNUMBER(SEARCH("sep",B2)),"9")),(IF(ISNUMBER(SEARCH("aug",B2)),"8")),(IF(ISNUMBER(SEARCH("jul",B2)),"7")),(IF(ISNUMBER(SEARCH("jun",B2)),"6")),(IF(ISNUMBER(SEARCH("may",B2)),"5")),(IF(ISNUMBER(SEARCH("apr",B2)),"4")),(IF(ISNUMBER(SEARCH("mar",B2)),"3")),(IF(ISNUMBER(SEARCH("feb",B2)),"2")),(IF(ISNUMBER(SEARCH("jan",B2)),"1"))
The questioner said "I get #Value!"
This is not a surprise because it is essentially a series of nine, self-contained, unrelated if statements, each separated by a comma. It is an invalid statement.
However, if the if statements were nested, then the formula would work. Something along these lines:
=IF(ISNUMBER(SEARCH("jan",B2)),"1",IF(ISNUMBER(SEARCH("feb",B2)),"2",IF(ISNUMBER(SEARCH("mar",B2)),"3")))
Formula 2
=IF(ISNUMBER(SEARCH("dec",B2)),"12",IF(ISNUMBER(SEARCH("nov",B2)),"11")),IF(ISNUMBER(SEARCH("DSH_KnowBe4_BirthMonth_Oc",B2)),"10"))
So close and yet so far... This statement uses the nested approach mentioned above. There is a major typo for the October search (instead of searching for "oct", the formula searches for "DSH_KnowBe4_BirthMonth_Oc") though this doesn't cause the formula to fail.
Failure is caused by two things:
1) The double bracket following "11")) in the "November" search. There should be zero brackets here.
2) The formula needs an additional closing bracket.
Two other things to note:
1) in the event of a match, the value returned is a string not an integer.
2) there's no provision to return a value in the event of a failure to match.
Working IF statement formula
The following formula, consisting of nested IF statements, works as intended by the questioner.
=IF(ISNUMBER(SEARCH("jan",B2)),"1",IF(ISNUMBER(SEARCH("feb",B2)),"2",IF(ISNUMBER(SEARCH("mar",B2)),"3",IF(ISNUMBER(SEARCH("apr",B2)),"4",IF(ISNUMBER(SEARCH("may",B2)),"5",IF(ISNUMBER(SEARCH("jun",B2)),"6",IF(ISNUMBER(SEARCH("jul",B2)),"7",IF(ISNUMBER(SEARCH("aug",B2)),"8",IF(ISNUMBER(SEARCH("sep",B2)),"9",IF(ISNUMBER(SEARCH("oct",B2)),"10",IF(ISNUMBER(SEARCH("nov",B2)),"11",IF(ISNUMBER(SEARCH("dec",B2)),"12",NA()))))))))))))
Note, the formula uses the NA() function to return #N/A if there is no match.
VLOOKUP alternative
Though the above-mentioned formula works, I find it complicated and inflexible. My preference in situations like this is VLOOKUP. My equivalent formula would be:
=VLOOKUP(RIGHT(B2,LEN(B2)-SEARCH("_",B2)),Sheet2!$A$2:$B$13,2,FALSE)
Using January as an example: BirthMonth_Jan, the formula lookup works like this:
RIGHT(B2,LEN(B2)-SEARCH("_",B2))
1) search for the underline character SEARCH("_",B2),
2) deduct the result from the total length LEN(B2)-SEARCH("_",B2) to give the number of characters to the right of the underline.
3) get all the characters to the right of the underline RIGHT(B2,LEN(B2)-SEARCH("_",B2)). This is the lookup value
4) Create a reference table on another sheet (refer screenshot); lookup this table and return column 2 (the number for that month).
5) If there is no valid result, VLOOKUP automatically returns #N/A.
The reference table on a separate sheet:
Not sure what you are trying to do with the formula but if your "BirthMonth_" text is consistent, you can use :
=MONTH(DATEVALUE("1 "&SUBSTITUTE(A12,"BirthMonth_","")&" 2018"))
Having a view of your data and expected result would help if this is not what you're after.
It is seems just possible what you might want is:
=MONTH(MID(B2,SEARCH("BirthMonth_",B2)+11,3)&0)
Returns a Number.

Check if 2 cells are blank excel

Im trying to write a formula that will check if 2 cells in a row are blank and if they are / arnt output true / false. Ive been working with isblank() and have put together this :
=IF(ISBLANK(L2) AND ISBLANK(N2), blank, not blank) but it returns a formula parse error, any ideas why this might be ?
Im doing this inside of google spreadsheets, so ideally id prefer not to use vba.
You're using an AND operator from a language that Excel can't compile.
In Excel it's an AND function with syntax:
AND(logical1, [logical2], ...)
Also the returns, being strings, need to be within double quotes in Excel functions so:
=IF(AND(ISBLANK(L2),ISBLANK(N2)),"blank", "not blank")
=if(and(isblank(L2),isblank(N2)),"blank","notblank")

Excel formula Iferror

I have a drop down list (data validation) that populates other cells using vlookup that pulls data from a separate worksheet. I'd like to include an error message if the field is blank like "No data entered". However, I am getting "0" instead. Here is the formula I used:
=IFERROR(VLOOKUP(ChildName,Children,6,FALSE),"No data entered")
I then changed this to an ISERROR:
=IF(ISERROR(VLOOKUP(ChildName,Children,5,FALSE))=FALSE,"No data entered", VLOOKUP(ChildName,Children,5,FALSE))
This gives the error message appropriately but now my drop down list does not populate the other cells!
What am I doing wrong? Thank you!
Looking at your formulas, I see two noteworthy points:
in the IFERROR you return the 6th column, in the ISERROR, the 5th!
in the ISERROR, you show the error message when something is found, as you say =IF(ISERROR=FALSE,ErrorMsg,...)!
To solve your problem, simply use this formula: =IF(ChildName="","No data entered",IFERROR(VLOOKUP(ChildName,Children,6,0),"Cannot find "&ChildName))
Ah, I see! Check out this question - Have Excel formulas that return 0, make the result blank. It shows all ways.
My favorite is =IFERROR(1/1/VLOOKUP(ChildName,Children,6,0),"No data!"). Only works with numbers though.
Else, use =IF(VLOOKUP(ChildName,Children,6,0),VLOOKUP(ChildName,Children,6,0),"No data!").
To be on the safe side, this version should take care of all potential issues: =IFERROR(IF(VLOOKUP(ChildName,Children,6,0),VLOOKUP(ChildName,Children,6,0),"No data!"),"No data!")

Resources