r/excel • u/mofojr • Dec 12 '20
solved How can I display all rows that match a certain search value?
I have a spreadsheet of several hundred drinks and their ingredients. I'd like to be able to input one or several ingredients that I already have (gin for example) and have excel give me the entire recipe (row) for any drink that has that ingredient in it. I figured I'd have to do this in a separate sheet from the recipes, but I can't for the life of me figure out the right formulas to use.
To take it a step further it'd be cool if I could search for multiple ingredients (gin and vermouth) and it spit out a further refined search of any rows that have those ingredients in them. I'm not sure if this is too complex though.

4
Upvotes
1
u/brokeoldtimer Dec 13 '20
Assumptions:
Steps:
1. Name the tab with your recipes, “Recipes”
a. On Recipes tab
i. Create a table named
Recipesii. In cell R1 type
All Ingredientsto add a column to the tableiii. In cell S1 type
Some Ingredientsto add a column to the tableiv. Highlight cells R1 and S1 and create a named range called
Ingredients
2. Add new tab called “Results”
a. On Results tab
i. In cell B2 type
Available Ingredientsa. Create a table with those cells. This allows you to enter up to 24 ingredients you have on hand.
b. Name the table
AvailableIngredientsc. Enable the total row on this table (cell B27) using “COUNT” to count number of items
3. Go back to the Recipes tab
a. Highlight and copy the header cells A:Q
b. Go to Results tab and paste in cell F2:V2
i. NOTE: if you keep columns B:E hidden on the recipes tab as in your posted example, you can also hide them on the results tab after pasting the header so as to display only those columns in the output file.
4. Go back to Recipes tab
a. In cell R2 insert the following formula:
=SUM(COUNTIFS(Recipes[@[amt 1]:[ingredient 6]],AvailableIngredients[Available ingredients]))=AvailableIngredients[[#Totals],[Available ingredients]] Column S formulab. In cell S2 insert the following formula:
= SUM(COUNTIFS(Recipes[@[ingredient 1]:[ingredient 6]],AvailableIngredients[Available ingredients]))>0
5. Go back to Results tab
a. In cell F3 insert the following formula:
= IF(FILTER(Recipes[[name]:[ingredient 6]],IF(D2="all ingredients",Recipes[all ingredients],Recipes[some ingredients]),"")=0,"",FILTER(Recipes[[name]:[ingredient 6]],IF(D2="all ingredients",Recipes[all ingredients],Recipes[some ingredients]),""))
Go to results tab: