The below formula helps to Start from ASD and before the slash it prints all the data.
Query:
Now as per the requirement, i need to search for two words with OR condition.
For eg it should either start with ASD or DEF I tried with OR condition but that is not working.
Can someone pls guide in this.
Working Formula:
=IF(ISNUMBER(SEARCH("ASD",A11)),MID(A11,SEARCH("""",A11)+1,SEARCH("/",A11)-1-SEARCH("""",A11)),"")
With OR Condition(which is not working)
=IF(ISNUMBER(SEARCH("ASD",A11) OR SEARCH("DEF",A11)),MID(A11,SEARCH("""",A11)+1,SEARCH("/",A11)-1-SEARCH("""",A11)),"")
It has to look like:
=IF(OR(ISNUMBER(SEARCH("ASD",A11)), ISNUMBER(SEARCH("DEF",A11))),MID(A11,SEARCH("""",A11)+1,SEARCH("/",A11)-1-SEARCH("""",A11)),"")
It seems that the order of the operations in your formula is the issue.
Example:
OR – =IF(OR(Something is True, Something else is True), Value if True, Value if False)
cf: https://support.microsoft.com/en-us/office/using-if-with-and-or-and-not-functions-d895f58c-b36c-419e-b1f2-5c193a236d97
My best guess is that your formula should be
=IF(OR(ISNUMBER(SEARCH("ASD",A11), SEARCH("DEF",A11))),MID(A11,SEARCH("""",A11)+1,SEARCH("/",A11)-1-SEARCH("""",A11)),"")
Related
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.
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,"")
I have the following formula:
=IF(AND(A1=0,A3="","1 item"),
IF(AND(A1=0,A3="Exclude","1 item"),
IF(AND(A1=1,A3="Exclude","1 item","2 items"))))
3 combinations of cell values in A1 and A3 return text which I'm calling "1 item"
Only 1 combination of cells value returns text which I'm calling "2 items".
The only combination to return "2 items" is where A1=1 AND A3="".
The formatting is wrong but I'm not sure where.
Any help would be greatly appreciated.
this is the correct formula -
brackets of AND() were not properly closed.
=IF(AND(A1=0,A3=""),"1 item",IF(AND(A1=0,A3="Exclude"),"1 item",IF(AND(A1=1,A3="Exclude"),"1 item","2 items")))
Excel's IF expects three parameters: Condition, What to do if condition is TRUE, and what to do if condition is FALSE.
I'll re-format your formula so you can see where the error is:
IF( AND(A1=0,A3="","1 item") ,
IF(AND(A1=0,A3="Exclude","1 item"),
IF(AND(A1=1,A3="Exclude","1 item","2 items")
)
)
)
As you can see
For the first IF you are not providing what to do if condition is FALSE,
The same for the second IF,
The third IF has no definition of what to do if the condition is TRUE or FALSE.
Hope this helps you.
UPDATE
Following your comment (which is still not clear to me), hereinafter I'm providing simple rules you may use to construct your formula correctly:
Write your formula as a piece of text (like the example I show above) so that you can easily read, edit and verify it,
Remember that Excel's IF has three parameters: Condition, result when condition is TRUE and result when condition is FALSE,
Within any of these three parameters, you can include whatever you want PROVIDED that the result is compliant with what the function expects for that parameter; for instance, writing for the first parameter 3=8 is completely legal since the result is FALSE (while 4=2*2 would yield TRUE).
Having this in mind, here is the formula I think you are looking for (WARNING!!! I'm not sure I understood what you need, but if not, changing it should be very easy for you now):
IF(AND(A1=1,A3=""),"2 items","1 item")
This is based on your wording: The only combination to return "2 items" is where A1=1 AND A3="".
column V is homework actual finish date
column W is required finish date
condition 1: if V is not blank, return value "ok"
condition 2: if "V is blank" and "W is blank", return value "ok"
condition 3: if "V is blank" and "W>=today()", return value "overdue"
I'm only able to combine condition 1 and 3 in my IF formula:
=IF(NOT(ISBLANK(V2)),"ok",IF(W2<=TODAY(),"over due","ok"))
Could anybody help me add condition two into my formula?
thanks for everybody's help/ im really new to stackoverflow.
and i have already learned something from everybody.
btw i made a typo in my condition 3, it should be "W<=today()" instead "W>=today()"
thanks
=if( and( not(isblank(v2)), not(isblank(w2)) ), "ok",
if( not(isblank(v2)), "ok",
if( and( isblank(v2), w2 >= today() ), "overdue", "ok" )
)
)
Paste this directly into the formula box and see how it works.
Let me see;
Your decision tree is missing one possible output; when V is blank, W !is blank and W<=today()
once you tell us what output means to you, we can easily help you.
Try this.
=IF(NOT(ISBLANK(V2)),"ok",IF(ISBLANK(W2), "ok",IF(AND(ISBLANK(V2),W2 >= TODAY()),"Over Due", "Error")))
As tip for future macros, try building them up a little at a time. For IF statements it can get tricky but this may help.
Write the first condition like this with 'Other Value' as a place holder.
=IF(NOT(ISBLANK(V2)),"ok","Other Value")
Once you have that bit working the way you like it then put in the false condition like this.
=IF(NOT(ISBLANK(V2)),"ok",IF(ISBLANK(W2),"ok","Other Value"))
And then finally add your last condition.
This is quite simple with one AND statement. First, redefine the logic you need for yourself: there are only two outcomes you care about: an assignment is unfinished and overdue, OR an assignment is finished/not yet due. So to write our IF statement, check only whether the assignment is unifinished and overdue. In any other case, the status will be the same.
Edit per comment
=IF(AND(ISBLANK(V1),W1<=TODAY(),W1>1),"overdue","ok")
I have 3 columns in excel that track when someone answered a call by date. Each person is called up to 3 times, hence the 3 columns. I am trying to count the number of people that answered in July, so the first two columns could be pre-July, or the first column could be in July. My data looks a little like this.
A B C D
1 1st Call 2nd Call 3rd Call July
2 01/06/15 12/06/15 22/06/15 No
3 01/06/15 15/06/15 02/07/15 Yes
4 14/06/15 02/07/15 Yes
5 14/06/15 03/07/15 Yes
6 05/07/15 Yes
So regardless of whether they answered after 1, 2, or 3 attempts, if any of the 3 columns is in July it returns "Yes".
I have tried this formula,
=IF(A2="", "", IF(COUNTIF(A2:C2, month=7)>0, "Yes", "No"))
and
=IF(A2="", "", IF(COUNTIF(A2:C2, MONTH(A2:C2)=7)>0, "Yes", "No"))
But to no avail. Does anyone know how to achieve this?
EDIT
I have realised since I can use the following,
=IF(A2="","", IF(MONTH(A2)=7, "Yes", IF(MONTH(B2)=7, "Yes", IF(MONTH(C2)=7, "Yes", "No"))))
However i'm still curious if my first attempt is achievable.
Yes, you can do what you're attempting with a simple tweak to how you are declaring your 'array' of possible responses:
=OR(IF(A2="", "", IF(Month(A2:C2))=7, TRUE, FALSE)))
You will need to confirm this with CTRL + SHIFT + ENTER, rather than just ENTER. It will work as you are intuiting, by running over each cell with the formula If(Month(CELL)>0, TRUE, FALSE). It then gives us an array of responses, depending on the results. [something like {TRUE, FALSE, TRUE}].
Note that I needed to change "yes" and "no" to TRUE / FALSE, because then we can wrap the whole thing in an OR statement. Otherwise, it's hard to pick out from your array of "yes"'s and "no"'s whether any of them are "yes". You can, if you need to, wrap this whole thing in an IF formula to convert TRUE to "yes", like so:
=IF(FORMULA ABOVE,"yes","no")
Why not just use an Or statement? =if(or(month(a2)=7,month(b2)=7,month(c2)=7),"Yes","No"). Then, you can use a countif to count how many "Yes" answers you have.
As for whether your first method would work, AFAIK it won't as the array in the formula won't work. Also, it's a little "overkill" to use an if countif > 0, then ... since all you want to know is if ANY of them are July, you could just use the above Or() statement.