Incorrect If formula - excel

As I'm still getting the hang of excel I'm not 100% sure why this formula isn't working!
=IF(OR(ISBLANK(L6),ISBLANK(M6)),"";IF( L6 >= M2,"True","False")
I'm trying to do a true, false check for cols L and M but as there are blanks in there I need to check for them as well. For the blanks, I just want to make them "".

As per Gowtham's comment, you are missing some brackets.
Use , or ; to delimit parts of the IF statement. Not both.
true and false are special words in Excel. They do not need to have quotes " around them like regular strings.
=IF(OR(ISBLANK(L6),ISBLANK(M6)),"",IF(A1>B1,TRUE,FALSE))
Edit
As per jsheeran's comment this can be simplified further as Excel will automatically evaluate A1>B1 to true or false.
=IF(OR(ISBLANK(L6),ISBLANK(M6)),"",A1>B1)

Related

Excel customer data validation for chars and numbers

I am trying to validate a combination of char and numbers that looks like this XXXX0000000.
I have tried this formula; =OR((LEFT(B2,3)="XXXX",LEN(B2)=11),AND(LEFT(B2,3)="XXXX",LEN(B2)=11).
The error message I receive is as follows:
excel error message
Title: "Excel customer data validation for chars and numbers"
...I have the feeling it's not just about validating XXXX0000000 but it's about the pattern of characters and numbers. Therefor try:
Formula in B1:
=IF(ISERROR(FILTERXML("<t><s>"&A1&"</s></t>","//s[translate(substring(.,1,4), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','')=''][string-length()=11][substring(.,5)*0=0]")),"Invalid","Valid")
Where:
//s[translate(substring(.,1,4), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','')=''] - Check if when we translate the first 4 characters to nothing this also equals empty string;
[string-length()=11] - Check that node is 11 characters long;
[substring(.,5)*0=0] - Check that substring from 5th position onwards equals zero when multiplied by zero.
Note: FILTERXML() is case sensitive and is currently checking for uppercase alpha-chars.
EDIT:
To use this in data-validation; Ditch the IF() since you don't need that in validation and nest the remainder in NOT():
=NOT(ISERROR(FILTERXML("<t><s>"&A1&"</s></t>","//s[translate(substring(.,1,4), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','')=''][string-length()=11][substring(.,5)*0=0]")))
When you select your range, make sure the validation rule has the topleft cell in the reference.
You have two formulas but no joining of them
IE you have an OR formula
=OR((LEFT(B2,3)="XXXX",LEN(B2)=11)
Which will return a true/false answer
You also have an AND formula
=AND(LEFT(B2,3)="XXXX",LEN(B2)=11)
Which will return a true/false answer
when you work through it you are being given a return of:
=True(or false), true (or false)
That isn't a formula and is causing the error output
I think you want to use an IF statement to join them and get an output as desired:
E.g.
=If(OR(LEFT(B2,3)="XXXX",LEN(B2)=11),AND(LEFT(B2,3)="XXXX",LEN(B2)=11), DO SOEMTHING IF TRUE, DO SOMETHING IF FALSE)
I suggest this:
OR(LEFT(B2,3)="XXX",LEN(B2)=11,AND(LEFT(B2,3)="XXX",LEN(B2)=11))
It corrects the number of characters error and sorts the logic.

EXCEL IF this AND that OR this AND that formula

Im struggling to get the correct formula for the following logic:
I have used an asterisk as a wildcard.
Where I have used it in the middle of the string it replaces 2 characters, end of the string-2 characters and beginning of the string-6 characters. I am not quite sure how to do this correctly.
IF K3="4 x 4" AND L3="FA*FR*" OR
IF K3="A4" AND L3="FA*FR*" OR
IF L3="*DK"
THEN "0"
ELSE "1"
Here is one of the many attempted formulas with no luck.
=IF(OR(AND(L3="FA*FR*",K3="4 x 4")), AND(L3="FA*FR*",K3="A4"),(L3="*DK") "0","1")
How could I make this work?
IF does not allow wildcard, you will need to add SEARCH to it:
=IF(OR(AND(ISNUMBER(SEARCH("FA*FR*",L3)),K3="4 x 4"), AND(ISNUMBER(SEARCH("FA*FR*",L3)),K3="A4"),ISNUMBER(SEARCH(L3,"*DK"))),0,1)

IF ISNUMBER SEARCH - distinguish between similar text

Hoping someone smarter than myself can help:
Column F contains either of the words below, and I want to excel formula to return whether the data is "White" or "Pink"
Ban
Bandearg
=IF(ISNUMBER(SEARCH("Ban",F2)),"White",IF(ISNUMBER(SEARCH("Bandearg",F2)),"Pink")
The problem is that everything returns as "White" as it is finding "Ban" in both. Presume I am using the formula wrong.
Bán is the Irish for White and Bándearg is the Irish for Pink!
As per my comment, simply swap them around:
=IF(ISNUMBER(SEARCH("Bandearg",F2)),"Pink",IF(ISNUMBER(SEARCH("Ban",F2)),"White"))
ISNUMBER checks wheather or not SEARCH returns a number (meaning the substring is found starting at that index/position) or an #VALUE error. In the first case, it will return TRUE, otherwise FALSE continueing with the second nested IF. Note that this formula will return FALSE if "Ban" isn't found at all.
Maybe just simply add a space behind the criteria and the result value, and your formula become :
=IF(ISNUMBER(SEARCH("Ban ",F2&" ")),"White",IF(ISNUMBER(SEARCH("Bandearg ",F2&" ")),"Pink"))
If those words are all that the cell contains, you can simply use:
=IF(A1="Ban","White",IF(A1="Bandearg","Pink",""))
or, in later versions of Excel (2019+ or O365):
=IFS(A1="Ban","White",A1="Bandearg","Pink",TRUE,"")

Excel Multiple If Statements showing False

I have this IF statement:
=IF(AG3<=7,"1",IF(15<=AG3<=21,"2",IF(22<=AG3<=28,"3",IF(29<=AG3<=35,"4",IF(36<=AG3<=42,"5",IF(43<=AG3<=49,"6",IF(50<=AG3<=56,"7")))))))
but either it gives me a 1 or "FALSE"
All the values are within the ranges and should be showing various numbers
Excel does not use 50<=AG3<=56. The way Excel will read this is it will resolve AG3<=56 which will resolve to TRUE or FALSE which have the values of 1 and 0 respectively. And since 50 is greater than both those it will always return FALSE and since you did not specify a final false argument Excel returns FALSE
It needs to be AND(50<=AG3, AG3<=56)
Also "1" returns a number as text and not a true number, remove the quotes.
So:
=IF(AG3<=7,1,IF(AND(15<=AG3,AG3<=21),2,IF(AND(22<=AG3,AG3<=28),3,IF(AND(29<=AG3,AG3<=35),4,IF(AND(36<=AG3,AG3<=42),5,IF(AND(43<=AG3,AG3<=49),6,IF(AND(50<=AG3,AG3<=56),7,"Value not in specs")))))))
But based on your criteria you could use:
=IF(OR(AND(AG3>=8,AG3<=14),AG3>56),"Not to Spec",MATCH(AG3,{-1E+99,15,22,29,36,43,40}))
Don't use Nested IFs if you can avoid it. Instead, use a banded VLOOKUP: it's many times more efficient, and a heck of a lot simpler to troubleshoot. Something like the answer here:
Excel IF statement Not returning the appropriate Value
In your case, here's your lookup list:
Note that since you haven't specified what should happen between 8 and 14 or over 57 I have simply put =NA() in those bands.
And here's the result for a range of numbers:
...and here's the formula that was used in the second column of that second table (using table notation):
=VLOOKUP([#Value],Table3,2,TRUE)

Excel 2013 - Nested IF(ISERROR(SEARCH not 'seeing' final statement

I'm struggling to see why the below isn't working for the final statement:
=IF(ISERROR(SEARCH("Investment Commentary",E73)), IF(ISERROR(SEARCH("Quarterly Update",E73)),"Quarterly Update"),"Investment Commentary")
So in Column C is my formula, and Column E contains text I'm searching.
My original formula has 12 of these and they all work, except for the last one.
I thought perhaps I'd hit a limit, but for some reason it refuses to see the final IF statement and simply returns FALSE.
Any help would be much appreciated!
Your first IF has a TRUE and FALSE part.....but the TRUE part consists of an IF statement with no FALSE part, so if the first IF is TRUE and the second is FALSE you get FALSE, you need to put something where I've indicated:
=IF(ISERROR(SEARCH("Investment Commentary",E73)), IF(ISERROR(SEARCH("Quarterly Update",E73)),"Quarterly Update","Something Here"),"Investment Commentary")

Resources