Sequentially search multiple lists in Excel?

axelgeorge

New Member
Joined
May 2, 2012
Messages
3
Hi Excel fans,

I'm puzzling over a problem, and I hope you guys can help. Can you think of a way to do the following...

Suppose I'm a grocer and I use a spreadsheet to track my inventory. I sell fruits, vegetables, and dried spices. On one worksheet in my Excel file, I create the following lists:

FRUITS
VEGETABLES
Apple
Potato
Orange
Celery
Banana
Cucumber
Grape
Radish
Pear
Broccoli

<tbody>
</tbody>

Then on a second worksheet, I have my actual inventory, which is this:
ITEM
QNTY
PRICE
CLASSIFICATION
Banana
50
$.25
Cucumber
100
$1
Dried Oregano
30
$5
Broccoli
100
$2
Radish
40
$1

<tbody>
</tbody>

I need a formula for the "Classification" cells of the Inventory. For each "Classification" cell, I want the formula to do the following:
  1. Search for the corresponding "Item" in the "Fruits" list; if found, then put "FRUIT" in the Classification field.
  2. If not found, search for the corresponding "Item" in the "Vegetables" list; if found, then put "VEGETABLE" in the Classification field.
  3. If still not found, put "SPICES" in the Classification field.

So using my toy example:
  • The formula for the first row would search for "Banana" in the "Fruits" list. Because the desired text sting is found, the formula enters "FRUIT" into the Classification field.
  • The formula for the next row would search for "Cucumber" in the "Fruits" list. It would fail to find it, so then it would next search the "Vegetables" list. Because the desired text sting is found there, the formula enters "VEGETABLE" into the Classification field.
  • The formula for the next row would search for "Dried Oregano" in the "Fruits" list. It would fail to find it, so then it would next search the "Vegetables" list. Because the desired text sting is not found there, the formula enters "SPICES" into the Classification field.

Does this make sense? I have no idea if Excel can handle this level of automation, but I suspect there must be a way to do this.

Many thanks!
-G
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Really the best way to do this is to put all your items in one list, with an additional column to describe the category. Then you could do a simple vlookup and you'd be all done.

But, if you must go this route, try:

=IFERROR(VLOOKUP(K14,I$8:J$10,2,0),IFERROR(VLOOKUP(K14,L$8:M$10,2,0),"Spices"))

Where:

K14 is the lookup value

I8:J10 is list #1

L8:M10 is list #2
 
Upvote 0

Forum statistics

Threads
1,215,455
Messages
6,124,935
Members
449,195
Latest member
Stevenciu

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