Same value against each cell from a single column? - excel

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

Related

Excel: Grouping and restructuring data in Excel

In Excel, I want to convert the table on the top (Initial data) into the one at the bottom (Desired output).
I want to group the items in the second row by the first row, and then generate one column per unique value of the first row and list the items of the corresponding group in that column.
Is there a way to do that without manually copying cells?
Table: Initial data
Fruit
Banana
Fruit
Apple
Fruit
Grape
Vegetable
Spinach
Vegetable
Eggplant
Table: Desired output
Fruit
Vegetable
Banane
Spinach
Apple
Eggplant
Grape
If you have access to the UNIQUE and FILTER functions (Excel 365), you could accomplish this as follows.
Assuming your data is in A1:B5. In D1 enter:
=TRANSPOSE(UNIQUE($A$1:$A$5))
This will get you the unique values from the cells in A in D1:E1. Then in D2 enter:
=FILTER($B$1:$B$5,$A$1:$A$5=D1)
And drag to the right.
I.e. you do this:
Result:

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.

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

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

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

Multiple vlookups in one cell

Ok I have two vlookups that both search from the same array but with different criterias.The first vlookup would search for the Price category. The second vlookup would seek the type of product.
This is an example array:
ID Price Type
1 Banana Fruit
2 Apple Fruit
3 Orange Fruit
4 Corn Flakes Cereal
5 Monster Energy Drink
The syntax would be:
Search for the first vlookup, if there is no results, try to search for the second vlookup.
If the first or second vlookup is true, then return value ID.
I have already made the vlookups but I have no idea how to combine both in one cell
Edit: Vlookups
=Vlookup(A2,E4:G8,2,0)
=Vlookup(B2,E4:G8,2,0)
And the lists:
A column B column
List 1 List 2
Banana Hardware
Carrot Vegetable
Orange Chocolate
Mango Candy
Fruit
It may be as simple as this:
=IFERROR(Vlookup(A2,E4:G8,2,0),Vlookup(B2,E4:G8,2,0))
Try to find one, if it fails try the other.
This formula returns corressponding ID if found value from A2 or B2 in ranges F4:F8 or G4:G8 respectively, or "not found in both columns" if both values not found:
=IFERROR(INDEX(E4:E8,IFERROR(MATCH(A2,F4:F8,0),MATCH(B2,G4:G8,0))),"not found in both columns")

Resources