I intend to find difference between two cells use excel formula only.
Values in two cells are separated by comma. However, there is no space near the comma.
Assume in B2, the value is
apple pie,fish,cheese
And in B3, the value is
apple pie,cheese,fish,vegetables,banana
I have to get vegetables,banana in E2
I am thinking about use EXACT function
=exact(B2,B3)
However the result returns FALSE with no doubt as those values in two cells are not match exactly.
I also think to use MATCH function but the result is #N/A.
=MATCH(B2,B3,0)
For the result, what I need is to get
vegetables,banana
Is it possible to achieve this? Grateful for your advice please. Thank you.
Reference
Find the difference between two cells
Difference between two cells in third cell
I am sorry I made mistakes in my first version in this post, I expect the result is
vegetables,banana
If in javascript, (I just use as example to show what I try to do in the excel)
I can use something like this
Array.prototype.diff = function(x) {
return this.filter(function(y) {return x.indexOf(y) < 0;});
};
//to get the result
[apple pie,cheese,fish,vegetables,banana].diff([apple pie,fish,cheese])
//the result will return
vegetables,banana
So I would like to know is it possible to use excel formula to do that? Thank you very much.
Related
I'm trying to do a search for multiple strings in a cell with an AND-condition in Excel
E.g: I have a string HNSP1 and I want to find some cells has HN and 1
I'm using:
=IF(SEARCH({"HN","1"},B3),600000,"")
But the result is OR-condition
Does anyone know the answer?
I think you could just use an AND function along with IsNumber and Find to get what you need.
Try this in a cell reference B3 and you should get a true result and then return the appropriate value
=IF(AND(ISNUMBER(FIND("HN",B3),ISNUMBER(FIND("1",B3))),600000,"")
what I want to perform is:
if "SUMIF('NJ'!A:A,C3,'NJ'!I:I)≠0", return the value of the "SUMIF('NJ'!A:A,C3,'NJ'!I:I)"
if "SUMIF('NJ'!A:A,C3,'NJ'!I:I)=0", I want to use this formula "SUMIF('QJ'!A:A,C5,'QJ'!AC:AC)" to return the value.
How do I put all this formula in one single cell?
I just can't find the right answer on google, please help me ㅠ
Maybe something like this
Logic:
=IF(1;0;IF(1;2))
Your case, given your text description:
=IF(SUMIF('NJ'!A:A,C3,'NJ'!I:I)<>0;SUMIF('NJ'!A:A,C3,'NJ'!I:I);
IF(SUMIF('NJ'!A:A,C3,'NJ'!I:I)=0;SUMIF('QJ'!A:A,C5,'QJ'!AC:AC)))
First post so let me say Excel is NOT my strong suit. I am trying to achieve results using IF/OR, but that may be the wrong choice. All advice and direction will be appreciated.
I have a spreadsheet. Cell F2 will always have the text "TANK" or "CYLINDER". Cell C2 will always have a number. I need to return "PASS" or "FAIL" flag in cell G2 based on the value in C2, BUT those values differ based on the text in F2.
Explanation:
IF F2=TANK & C2<=19 - return PASS,
IF F2=TANK & C2>=20 - return FAIL,
or
IF F2=CYLINDER & C2<=20 - return PASS,
IF F2=CYLINDER & C2>=21 - return FAIL,
Below is one of many options I have tried and apparently I don't know what I'm doing. Any help is appreciated...Thanks
=IF(OR(F2="TANK",F2="CYLINDER"),IF(F2="TANK",IF(C2<=19,"PASS",IF(C2>=20,"FAIL")))),IF(F2="CYLINDER",IF(C2<=20,"PASS",IF(C2>=21,"FAIL")))
I haven't tested it much, but this should be what you are looking for:
=IF(AND(F2="TANK",C2<=19),"PASS",IF(AND(F2="CYLINDER",C2>=20),"FAIL",IF(AND(F2="CYLINDER",C2<=20),"PASS",IF(AND(F2="CYLINDER",C2>=21),"FAIL"))))
Here's a working version:
=IF(F2="TANK",IF(C2<=19,"PASS","FAIL"),IF(F2="CYLINDER",IF(C2<=20,"PASS","FAIL"),"not tank or cylinder"))
However, as you've noticed, long strings of functions within functions all on one line become extremely difficult to read and debug!
You can split up the intermediate steps in your formula into seperate cells - this makes it much easier to see what's going on at a glance. For example, you could have a cell that calculates the maximum value for pass/fail:
A1: if(F2="TANK", 20, if (F2="CYLINDER", 21, -1))
A2: if(C2>=A1,"PASS","FAIL")
(the "-1" is a final "else" case, if neither "TANK" nor "CYLINDER" is true)
Other ideas: if you've got three or more cases (tank, cylinder, widget, thimble...), you can use a vlookup function to return the maximum value. See https://support.office.com/en-us/article/VLOOKUP-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1
I want to get a formula with COUNTIFS, like
=COUNTIF(A1:A3,"<>"&"")
such that when A1 = 2, A2 = "", A3 = empty, it returns 1.
Notes:
A2 contains an empty string, as the result of a formula. A3 is a blank cell, with no formulas in it.
The formula posted returns 2.
I tried using various numbers of double quotes. I always get 2.
I tried using &CHAR(34)&CHAR(34). I get 2.
The solution posted in How do I get countifs to select all non-blank cells in Excel? is what I tried, it returns 2 (not useful).
The formula would actually be =COUNTIFS(range1,cond1,range2,cond2), that is why I cannot use something like
=ROWS(A1:A3)-COUNTIF(A1:A3,"") or =ROWS(A1:A3)-COUNTBLANK(A1:A3) (see this).
range1 and range2 would come from expressions with INDIRECT, but that is probably not relevant.
I have worked it out with =SUMPRODUCT(--(expression1),--(ISNUMBER(A1:A3))), but I am specifically asking about the possibility of using COUNTIFS. Discrimination of number vs. text (e.g.) is not relevant at this point.
Blank vs. Empty string is the source of "troubles" (see, e.g., this).
Excel itself is somewhat ambiguous with respect to the definition of BLANK. In my example, ISBLANK(A2) returns FALSE, but COUNTBLANK(A2) returns 1.
I am not interested in a user Function.
Use a SUMPRODUCT function that counts the SIGN function of the LEN function of the cell contents.
As per your sample data, A1 has a value, A2 is a zero length string returned by a formula and A3 is truly blank.
The formula in C2 is,
=SUMPRODUCT(SIGN(LEN(A1:A3)))
I was having this exact problem, and I just found out about the "?*" wildcard which searches for any one or more characters, thus avoiding the empty string problem--genius! See Jonathan Gawrych's answer (posted right after the selected answer) here:
Excel Countif Not equal to string length of zero
Not sure if this works for the OP, since it looks like the value in A1 could need to be handled as a number not a string, but it might help anyone else who arrived here looking for a text-parsing solution.
Is using SUM instead of COUNTIFS an option? If so, I've found it to be much more flexible for filtering data sets. For example:
=SUM(IF(NOT(ISBLANK(A1:A3)),IF(NOT(ISTEXT(A1:A3)),1,0),0))
(entered as an array formula). IF(NOT(ISBLANK(x))... filters out non-blanks, then IF(NOT(ISTEXT(x))... filters out non-text. Whatever survives the filters is counted by summing 1. You can add as many filters as necessary. If you wanted to filter out only empty strings but include other text entries you could use a filter like
IF(ISTEXT(x),IF(LEN(x)>0,1,0),0)
I'm trying to use an INDEX MATCH function to automate filling one spreadsheet using data from another. However, the sheet I am filling has people's names listed in two separate cells (e.g. "John" in A1, "Doe" in B1), while the sheet I am filling from has them listed as "DOE, JOHN Q." in one cell. A regular INDEX MATCH function would never give a result since no cell in the domain contains just the string "Doe." Is there any way to perform the function for cells that have the lookup value within the cell as a substring?
For reference, this is my attempt at this problem, which of course returns an error:
=INDEX(Sheet2!G2:Sheet2!G2340,MATCH(B3,ISNUMBER(SEARCH(B3,Sheet2!C2:Sheet2!C2340)),0))
I think you're on the right track. I think your initial formula should work but you need to make two changes:
Match criteria should be "TRUE" instead of "B3", as the result iof the ISNUMBER() function is a TRUE or FALSE
When entering the formula, press CTRL+SHIFT+ENTER instead of just ENTER, to make this an array function
Formula:
=INDEX(Sheet2!G2:Sheet2!G2340,MATCH(TRUE,ISNUMBER(SEARCH(B3,Sheet2!C2:Sheet2!C2340)),0))
If you wanted to search for both the first and last name, you could multiply two ISNUMBER() arrays together, and search for 1 instead of TRUE. This would get it to match both A3 and B3:
=INDEX(Sheet2!G2:Sheet2!G2340,MATCH(1,ISNUMBER(SEARCH(A3,Sheet2!C2:Sheet2!C2340))*ISNUMBER(SEARCH(B3,Sheet2!C2:Sheet2!C2340)),0))
Alternately, you could attempt to match both first and last names together with:
=INDEX(Sheet2!G2:Sheet2!G2340,MATCH(TRUE,ISNUMBER(SEARCH(B3&", "&A3,Sheet2!C2:Sheet2!C2340)),0))
Hope this helps. If I missed something, let me know!
You may concatenate the strings and provide that as an argument for MATCH or INDEX function. Still it would not work precisely as you do not have second names/initials like
MATCH(B1 & ", "& A1, Sheet2!C2:C2340, -1)
Although, you need to provide more details to get anything more from the StackOverflow community.