how can Ifind specific text in excel and return with specific value? - excel

How can I find text in a cell and output should be a return value?
For example:
Find Apple in Cell A1, if true it will output "return value for apple"
If the search is false, it will always search the next row. If true it will stop.
Fruits: Apple, Banana, Cherry
Fruits
A1: 1 Apple
A2: 2 Banana
A3: 5 Cherry
Return Value
B1: Apple
B2: Banana
B3: Cherry
Search Fruits
D1: Banana
D2: Cherry
D3: Apple

User search formula: You need to put your query more clearly.
=IFERROR(IF(SEARCH("Apple",A1)>0,"Apple",""),"")

Related

Check if array contains text from a list and when a value apears more then once display that value

What if I have 4 columns with data, and want the value that is more than once in those 4 columns(A-B-C-D).
apple pear melon grape
melon apple melon grape
pear melon melon pear
My list in column E is;
``
apple
pear
melon
grape
And what I would like is that in column F the value appears of the fruit that is more than once in a row.
So F1 should return nothing, F2 should return "melon", and F3 should return "pear, melon"
Is that posible with a formula?
Try,
In B1, array ("Ctrl"+Shift"+"Enter") formula copied down :
=MID(TEXTJOIN(", ",,FILTERXML("<a>A<b>"&SUBSTITUTE(TRIM(A1)," ","</b><b>")&"</b></a>","a|a/b[not(preceding::* =.)][following::* =.]")),4,999)
Remark : If you have Office 365, the above formula is normal entry.
If source data put in separated cells, then formula become >>
In F1, array ("Ctrl"+Shift"+"Enter") formula copied down :
=MID(TEXTJOIN(", ",,FILTERXML("<a>A<b>"&TEXTJOIN("</b><b>",,A1:D1)&"</b></a>","a|a/b[not(preceding::* =.)][following::* =.]")),4,999)
Remark : If you have Office 365, the above formula is also normal entry.

Same value against each cell from a single column?

I have one column like below:
Fruits:
Apple
Banana
Mango
Vegetables:
Broccoli
Tomato
Potatoes
I would like each value to have their parent name next to it in the cell like below:
Apple Fruit
Banana Fruit
Mango Fruit
Broccoli Vegetables
Tomato Vegetables
Potatoes Vegetables
How can I achieve this?
If your data is in column A, I am able to get the result with a helper column, by using the following formula in B1:
=FILTER($A:$A,($A:$A<>"")*(RIGHT($A:$A,1)<>":"))
This will result in your data excluding the titles (fruit, vegetable).
Then in C1 use the following formula and drag down:
=IFERROR(B1&" "&SUBSTITUTE(LOOKUP(2,1/(RIGHT(INDIRECT("$A$1:$A"&MATCH(B1,$A:$A,0)),1)=":"),INDIRECT("$A$1:$A"&MATCH(B1,$A:$A,0))),":",""),"")
As per my below screenshot put below formula to B1 cell.
=IF(RIGHT(A2,1)=":",LEFT(A2,LEN(A2)-1),B1)
Then put following formula to C1 cell
=FILTER(A2:B9,RIGHT(A2:A9,1)<>":")

How do I highlight a cell in Excel when all its content is contained in another column

I have a column (column A) that contains a list of text and another column (column B) that contains a smaller list, which is the values that I actually care about. Is it possible to only highlight cells in column A if all of its contents is listed in column B? If so, how?
A B
Apple Apple
Peach Pear
Apple, Pear Plum
Apple, Grape Kiwi
Apple, Pear, Kiwi      
Watermelon, Grape
So in the above example, I would like to highlight A1, A3, and A5 because all of the contents is listed somewhere in column B
use the following formula for the Conditional formatting:
=AND(ISNUMBER(MATCH(FILTERXML("<a><b>"&SUBSTITUTE($A1,",","</b><b>")&"</b></a>","//b"),$B:$B,0)))
If one does not have FILTERXML then they can use:
=SUMPRODUCT(--ISNUMBER(SEARCH("," &$B$1:$B$4&",",","&SUBSTITUTE(A1," ","")&",")))=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1
Noting that the range $B$1:$B$4 must be the size of the lookup values without any blanks

Conditional formatting for contains certain text from a range of values

How do you do conditional formatting to find out if range 2 contains the text value from range 1? For example check for Apple in red apple should highlight it.
I need to compare A3:A6 with C3:C7. The end result should be C3, C4 and C5 highlighted.
A B C
1 Range1 Range2
==========================
3 Apple Red Apple
4 Orange Green Apple
5 Pear Orange
6 Watermelon Banana
7 Kiwi
I tried this formula but it only check B3 against Range2 and skips B4 to B6.
=FIND($B$3:$B$6,C3)>0
It is possible and I had fun working on this problem but I really wish you had done some work as well - seeing your own effort would have been just as rewarding as solving the problem by myself.
The formula to be used with conditional formatting is:
=NOT(ISERROR(AGGREGATE(15, 6, ROW($A$1:$A$4)/SEARCH($A$1:$A$4,B1), 1)))=TRUE
It obviously works as a normal, non-array formula too:

I want to give same number to the duplicate data in excel

I want to give same number to the duplicate data in excel
A B
apple 1
apple 1
apple 1
ball 2
bat 3
dog 4
dog 4
goat 5
Sort your column A then insert the number 1 in cell B2 and the following function in cell B3 and copy down.
in cell B2=1
function in cell B3: =if(A3=A2, B2, B2+1)
Update
It is also possible to do it in a dynamic way that does not require sorting.
Paste the following formula in B2 and copy down the column:
=IFERROR(INDEX(B$1:B1,MATCH(A2,A$1:A1,0)),MAX(B$1:B1)+1)

Resources