Returning a value from an expansive list of value

gcandido

New Member
Joined
Nov 7, 2020
Messages
2
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi there,

I am trying to return one value from a list of values where this list will be growing in the future. So the spreadsheet looks like something as below

Annotation 2020-11-07 104851.jpg


Where column D will grow in the future. The issue I found so far is that the SEARCH formula only looks for one row at a time. Using =IF(OR(IFERROR(SEARCH($D$2,A2,1),0),IFERROR(SEARCH($D$3,A2,1),0),"Others")) is not an option as the Category list 1 grows, the OR starts to become extremely large. Is there another way to do that? any ideas? thanks a lot in advance

Gabriel
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi & welcome to MrExcel.
How about
+Fluff v2.xlsm
ABCD
1TextCatsCat 1
2the blue skyCat 1sky
3The red foxCat 1Red
4the blue lakeOthers
5
Main
Cell Formulas
RangeFormula
B2:B4B2=IF(MAX(IFERROR(SEARCH($D$2:$D$3,A2),0)),"Cat 1","Others")
 
Upvote 0
Another option if just looking at a single category.

But note row 5. That sort of thing could happen with your original formula too, or Fluff's.
From your sample data I suspect that you do not want that result since you appear to be searching for words rather than text strings. If so see the second sheet below.

20 11 08.xlsm
ABCD
1TextCatsCat 1
2the blue skyCat 1sky
3The red foxCat 1Red
4the blue lakeOthers
5credit ratingCat 1
Category 1
Cell Formulas
RangeFormula
B2:B5B2=IF(COUNT(SEARCH(D$2:D$3,A2)),D$1,"Others")



20 11 08.xlsm
ABCD
1TextCatsCat 1
2the blue skyCat 1sky
3The red foxCat 1Red
4the blue lakeOthers
5credit ratingOthers
Category 2
Cell Formulas
RangeFormula
B2:B5B2=IF(COUNT(SEARCH(" "&D$2:D$3&" "," "&A2&" ")),D$1,"Others")
 
Upvote 0
.. or are you looking to select from multiple categories at once more like your original sample?
Note (rows 9 & 10) that if matches are made from multiple categories, the left-most category is returned.

20 11 08.xlsm
ABCDEF
1TextCategoryCategory 1Category 2Category 3
2car is blueCategory 1BlueRedShy
3the girl is shyCategory 3BookHouses
4the book is on the tableCategory 1Banana
5 
6all houses are yellowCategory 3
7credit rating 
8I ate a bananaCategory 1
9I have a red bookCategory 1
10I have a blue bookCategory 1
11 
Category 3
Cell Formulas
RangeFormula
B2:B11B2=IF(A2="","",IFERROR(INDEX(D$1:F$1,AGGREGATE(15,6,(COLUMN(D$2:F$20)-COLUMN(D$2)+1)/ISNUMBER(SEARCH(" "&D$2:F$20&" "," "&A2&" ")),1)),""))
 
Upvote 0
Thanks a lot, @Peter_SSs The last post is the closest to what I want to achieve. But when I am formatting the formula in my spreadsheet it is not capturing other categories. Could you explain how to expand also to more categories? I am having so far around 15 categories.

best regards
 
Upvote 0
Could you explain how to expand also to more categories?
=IF(A2="","",IFERROR(INDEX(D$1:F$1,AGGREGATE(15,6,(COLUMN(D$2:F$20)-COLUMN(D$2)+1)/ISNUMBER(SEARCH(" "&D$2:F$20&" "," "&A2&" ")),1)),""))

Assuming your layout is similar to what I have but the extra categories are in columns G, H, I, J etc then change the red 'F' values above to the last category column, or even a column further to the right than that if you might add extra categories later.

You can also adjust the blue 20 values above if required. That simply needs to be a row at least as great as the greatest row number used in the category columns.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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