Searching for multiple terms in a cell with AND-condition - excel

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,"")

Related

I want to use 2 formula in one cell. If one formula returns 0 value, I want to use the other formular to return value

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)))

Vlookup Comparing 2 columns

=VLOOKUP(A2,C2:C238,2,FALSE) I have attached an image of my excel file and the 2 columns to be compared . I have written this formula but its throwing error.Thanks IN advance for helping
You're trying to reference the 2nd column in a table range that only has 1 column
Try using:
=VLOOKUP(A2,C2:C238,1,FALSE)
You might also want to make the range constant so use
=VLOOKUP(A2,$C$2:$C$238,1,FALSE)
Or if the column you're trying to return is column D then you'll need to use
=VLOOKUP(A2,C2:D238,2,FALSE)
I presume you want to check if there is a match. Use the MATCH function instead.
If you are simply trying to determine if the value of A2 exists in C2 then all you need to do is change your formula to the following:
=vlookup(A2, $C$2:$C$238,1,FALSE)
This formula will return the value of A2 if there is a match and #N/A if there is no match. If you want to make it look a little nicer you can use the following:
=if(iserror(vlookup(A2, $C$2:$C$238,1,FALSE))=FALSE,"Match exists","No match exists")
This basically just gives you the option to change the result value by changing the text within the quotes.

Search function with list of text values fails

I use formula =SEARCH({"N.","No.","#"},D5) and it fails if doesn't fit first option "N." how can I fix it?
Using =SEARCH({"N.","No.","#"},D5) formula when you will see how the formula calculates the result using Evaluate Formula, you'll notice
evaluates to
That means formula is searching only for "N."
Therefore to search for the existence of "N.","No.","#" in a cell, number of approaches are available like:
1. =IF(COUNT(SEARCH({"N.","No.","#"},D5)),1,"")
This formula will give 1 if any of the string in the cell exists.
2. =SUMPRODUCT(--ISNUMBER(SEARCH(find_text,D5)))>0
This formula will give TRUE if any of the three string exists else FASLE.

Difference between two cells

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.

Excel: VLOOKUP that returns true or false?

In Excel we have the VLOOKUP function that looks for a value in a column in a table and then returns a value from a given column in that table if it finds something. If it doesn't, it produces an error.
Is there a function that just returns true or false depending on if the value was found in a column or not?
You could wrap your VLOOKUP() in an IFERROR()
Edit: before Excel 2007, use =IF(ISERROR()...)
You still have to wrap it in an ISERROR, but you could use MATCH() instead of VLOOKUP():
Returns the relative position of an
item in an array that matches a
specified value in a specified order.
Use MATCH instead of one of the LOOKUP
functions when you need the position
of an item in a range instead of the
item itself.
Here's a complete example, assuming you're looking for the word "key" in a range of cells:
=IF(ISERROR(MATCH("key",A5:A16,FALSE)),"missing","found")
The FALSE is necessary to force an exact match, otherwise it will look for the closest value.
Just use a COUNTIF ! Much faster to write and calculate than the other suggestions.
EDIT:
Say you cell A1 should be 1 if the value of B1 is found in column C and otherwise it should be 2. How would you do that?
I would say if the value of B1 is found in column C, then A1 will be positive, otherwise it will be 0. Thats easily done with formula: =COUNTIF($C$1:$C$15,B1), which means: count the cells in range C1:C15 which are equal to B1.
You can combine COUNTIF with VLOOKUP and IF, and that's MUCH faster than using 2 lookups + ISNA. IF(COUNTIF(..)>0,LOOKUP(..),"Not found")
A bit of Googling will bring you tons of examples.
We've always used an
if(iserror(vlookup,"n/a",vlookup))
Excel 2007 introduced IfError which allows you to do the vlookup and add output in case of error, but that doesn't help you with 2003...
You can use:
=IF(ISERROR(VLOOKUP(lookup value,table array,column no,FALSE)),"FALSE","TRUE")
ISNA is the best function to use. I just did. I wanted all cells whose value was NOT in an array to conditionally format to a certain color.
=ISNA(VLOOKUP($A2,Sheet1!$A:$D,2,FALSE))

Resources