Search if cell contains one of many criteria then show ref # or ......

room99oat

New Member
Joined
Nov 11, 2015
Messages
14
Office Version
  1. 2019
Platform
  1. Windows
ABCDE
1Item nameTotal WeightlbCriterialb
2Dog lover40000=b2/e4Fish100
3So fishy20000=b3/e2Cat200
4Love bird30000=b4Dog300
5Super cat50000=b5/e3
6Big elephant1000=b6
7Small ant3000=b7

<tbody>
</tbody>

Hi, I need help for above tables.

How can I check if cells in column A contain criteria words in column E or not. And if it contains, I want the total weight on that cell divided by value of F column as shown on column C.

Thank you in advance.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try this, copied down...
=IFERROR(B2*INDEX($E$2:$E$4,MATCH(LOOKUP(9.99999999999999E+307,SEARCH($D$2:$D$4,A2),$D$2:$D$4),$D$2:$D$4,0)),"")
 
Upvote 0
=iferror(b2/index($e$2:$e$4,match(lookup(9.99999999999999e+307,search($d$2:$d$4,a2),$d$2:$d$4),$d$2:$d$4,0)),"")
 
Last edited:
Upvote 0
Here's an alternate version of the same formula:

=IFERROR(B2/LOOKUP(2^15,SEARCH($D$2:$D$4,A2),$E$2:$E$4),"")
 
Upvote 0
Just a comment:

9.99999999999999E+307 and 2^15 are hugely excessive but this does not affect anything.
The number should be >= the maximal expected value of SEARCH(substring,string).
So, for most practical purposes a 100 would be just enough.
 
Upvote 0
9.99999999999999E+307 is BigNum, essentially the largest number Excel can handle. Some people use it just so that they don't have to worry about calculating the actual max, or so that they can tell just by looking at the formula that it's looking for the largest number. 100 could mean many things, not just "the biggest number".

I used a smaller equivalent. The maximum number of characters in a cell is 32767. 2^15 = 32768, so that will definitely be larger than any value returned from SEARCH. Again, 100 would probably work fine, but why take the chance? Some of this is just personal choice, but what if someone copies and modifies the formula for a different purpose, not knowing what the 100 really means? It might break and they wouldn't know why.

So yes, 100 would probably be fine for most practical purposes in this situation, but there are other considerations as well.
 
Upvote 0
I use Eric's formula (2^15) and it works for the example table. BUT when i applied the formula to my data it doesn't work.
I already double check and everything seems correct.

I have 40 criteria and more than 2000 item lists. Does it case-sensitive?
 
Upvote 0
It works now!! Thank you all. Both formula are working fine. Thanks again.
 
Upvote 0

Forum statistics

Threads
1,215,350
Messages
6,124,430
Members
449,158
Latest member
burk0007

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top