简体   繁体   中英

Excel Formula & Conditional Formatting: How to match current cell in another table based on criteria

I have an excel tool that I use to make meal plans for clients. I select the client, choose pre-set meals from a list and compile them into a plan, and assign them to the individual.

I want to create a function/conditional formatting that highlights particular ingredients in any given meal plan, if the individual 'can't/won't eat' them. This is based off their individual preferences.


Sheet 1: Contains a table of client names, with an associated ID. There is a drop down box that allows the user to select who they are creating the plan for.

ID 选择器

Sheet 2: Contains a table of ingredients, with the furthest right column containing client IDs, as text, in the case a given ingredient is disliked by a client/s.

成分表

Sheet 3: Is where the meals (and ingredients) are listed, and then compiled into a plan. Here is where I would like the conditional formatting to be applied, highlighting ingredients if they are disliked by the client.

进食计划

Note: the sheets aren't actually in this order


I was messing around with this formula in a cell;

=IF(IFERROR(IF(FIND(ID,INDEX(IngredientTable,(MATCH(IngredientInMealPlan,Sheet2!A:A,0)),9))>0,"Dislike","Error"),"Error")="Dislike",IngredientInMealPlan,"")

Where;

IngredientTable = The table of ingredients, their values, and IDs/dislikes on Sheet 2

IngredientInMealPlan = Would be the the ingredient in question when the meals are compiled on Sheet 3

Sheet2:A:A = Column A, for looking up Ingredient names


I realise that the formula is a bit clunky, I wasn't really sure how to tighten it up. It did start to look like I might be heading in the right direction with it, but there are several issues;

  • I'm not sure how to work around IngredientInMealPlan relating to a specific cell, I don't think the formula will work if it's a range
  • I'm not sure how to work this into conditional formatting, and apply it to the range D:D on Sheet 3 where the meal plans are compiled.

I'm open to ideas on how to implement this. While I realise it would make it easier, I don't really want to add an additional column to the Ingredient Table on Sheet 3. I'm useless with VBA.

I had some help, this formula works and solves my problem:)


=IFERROR(FIND('Sheet1'!$G$1,(INDEX(Ingredients!I:I,MATCH(D2,Ingredients!A:A,0)))),0)>=1

Where;

D2 - is the first Ingredient on 'Sheet 3'. As the conditional formatting is applied to column D, this reference changes down the column (eg D3, D4... Etc.)

Ingredients:A:A - is the column for the actual ingredient name

Ingredients:I:I - is the column for Dislikes

'Sheet1',$G$1 - is the client ID, that has been selected


As the formula finds the client ID in the dislike column, the formatting is applied, alerting the user to the specific ingredient that particular client dislikes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM