too many nested IF statements

joebro

New Member
Joined
Jul 19, 2020
Messages
6
Office Version
  1. 2013
Platform
  1. Windows
Hi, my data has a list of vegetables which I want to categorise. See data/results columns below. My formula works but i have hit the limit to how many nested IF statements I can use, also it's very cumbersome, there must be a better more elegant way to do this? Thanks in Advance, Joe

=IF(ISNUMBER(SEARCH("Beans",A13)),"Peas, Beans, Corn & Asparagus",IF(ISNUMBER(SEARCH("Peas",A13)),"Peas, Beans, Corn & Asparagus",IF(ISNUMBER(SEARCH("Corn",A13)),"Peas, Beans, Corn & Asparagus",IF(ISNUMBER(SEARCH("Asparagus",A13)),"Peas, Beans, Corn & Asparagus",IF(ISNUMBER(SEARCH("Beet",A13)),"Carrots & Root Vegetables",IF(ISNUMBER(SEARCH("Carrots",A13)),"Carrots & Root Vegetables","Other Veg"))))))


column data / column results

Beetroot / Carrots & Root Vegetables
Beans / Peas, Beans, Corn & Asparagus
carrots / Carrots & Root Vegetables
Peas / Peas, Beans, Corn & Asparagus
Potatoes / Other Veg
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Maybe use VLOOKUP

Book1
AB
1Beetroot Carrots & Root Vegetables
2Beans Peas, Beans, Corn & Asparagus
3carrots Carrots & Root Vegetables
4Peas Peas, Beans, Corn & Asparagus
5Potatoes Other Veg
6
7
8Beans Peas, Beans, Corn & Asparagus
Sheet1
Cell Formulas
RangeFormula
B8B8=VLOOKUP(A8,$A$1:$B$5,2,0)
 
Upvote 0
VLOOKUP or INDEX/MATCH is the way to go. This being said, you should be able to insert 64 IF functions in XL2013?
 
Upvote 0
Column B is not data I can use, It's the results column that is defined by what is in column A. So in need to search column A and when i find a match assign Colum B a text string much like my formula was doing
 
Upvote 0
Maybe set up a list (as in cells A2 - A6) and then use one of the INDEX formulas below.

Book1
AB
1List
2 Carrots & Root Vegetables
3 Peas, Beans, Corn & Asparagus
4 Carrots & Root Vegetables
5 Peas, Beans, Corn & Asparagus
6 Other Veg
7
8Find
9Corn Peas, Beans, Corn & Asparagus
10
11 Peas, Beans, Corn & Asparagus
Sheet1
Cell Formulas
RangeFormula
B9B9=IFERROR(INDEX($A$2:$A$6,MATCH(TRUE,ISNUMBER(SEARCH(A9,$A$2:$A$6)),0)),"Other Veg")
B11B11=IFERROR(INDEX($A$2:$A$6,MATCH("*"&A9&"*",$A$2:$A$6,0)),"Other Veg")
 
Upvote 0

Forum statistics

Threads
1,216,115
Messages
6,128,919
Members
449,478
Latest member
Davenil

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