If cell A1 contains (shirt,hat, or pants) then display (clothes) in B1 , If cell A1 contains (frog,snake,or lizard) then display (reptile) in B1 etc.

bvalkenb

New Member
Joined
Oct 2, 2014
Messages
13
Please help. I have been researching and have been unable to find the correct solution.

Situation:

Column A has 1000's of qualitative survey responses. I would like to label / categorize the survey responses in a corresponding cell.

For example:

If Cell A1 contains: "shirt","pants","hat", then display "clothes" in B2

If Cell A1 contains: "sun", moon", "stars", then display "space" in B2

This formula needs to continue on because I have about 50 categories which will have keywords associated with them.

Thank you in advance for your suggestions.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
To take this formula one step further:

Is it possible to code one survey response under two categories? Currently, if a cell has two separate key words, it is labeled "#N/A".

For example.. Survey response 1: It is a starry night in July

Keyword table:

Starry - Space

July - Season

So formula outcome would be: Space, Season

This might be a stretch, and even if I just continue to use the current formula, I am beyond happy that you could help with such a seemingly tough problem.

If though this would be a simple edit to the formula it would prove very much a time-saver in coding the thousands of responses.
 
Upvote 0
bvalkenb,

Here is a rough and ready possibility for a response satisfying two categories......

Excel 2007
ABCDEFGHI
1I see the sun wearing a hatspace, clothesshirtclothes
2moon pants are coolspace, clothespantsclothes
3No blue shirtclotheshatclothes
4stars are not bluespacesunspace
5moonspace
6starsspace
Sheet8
Cell Formulas
RangeFormula
B1{=IFERROR(LOOKUP(9.999999999E+307,MATCH("*"&$H$1:$H$6&"*",A1,0),$I$1:$I$6),"")&IF(SUM(IFERROR(MATCH("*"&$H$1:$H$6&"*",A1,0),0))>1,", "&INDEX($I$1:$I$6,MATCH(1,MATCH("*"&$H$1:$H$6&"*",A1,0),0),0),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.

It requires confirming with Ctrl + Shift + Enter

Hope that helps.
 
Last edited:
Upvote 0
Alternatively, a standard formula possibility ???


Excel 2007
ABCDEFGHI
1I see the sun wearing a hatspace, clothesshirtclothes
2moon pants are coolspace, clothespantsclothes
3No blue shirtclotheshatclothes
4stars are not bluespacesunspace
5pants pants pants pants sunspace, clothesmoonspace
6sun sun sun pantsspace, clothesstarsspace
7sun starsspace, space
8
Sheet8
Cell Formulas
RangeFormula
B1=IFERROR(LOOKUP(2,MATCH("*"&$H$1:$H$6&"*",A1,0),$I$1:$I$6),"")&IFERROR(LOOKUP(2,MATCH("*"&SUBSTITUTE($H$1:$H$6,LOOKUP(2,MATCH("*"&$H$1:$H$6&"*",A1,0),$H$1:$H$6),"§x§")&"*",A1,0),", "&$I$1:$I$6),"")
 
Upvote 0
Scott or Tony:

When I am using the above formula (last one posted), I run into one problem:

The formula codes short responses perfectly, but when the survey response exceeds ~200 characters, the formula returns no key words found in the comment. Do you know what might be the cause of this character limit in the survey response coding?

Thank you again,

Bo
 
Upvote 0
Bo,

There is a character limit of 255 on the Lookup value within the MATCH function !!!!!

Try the below where I have used SEARCH instead of MATCH and you should be good for several thousand characters
Excel 2007
AB
1Moon and pantsspace, clothes
Sheet2
Cell Formulas
RangeFormula
B1=IFERROR(LOOKUP(2,SEARCH("*"&$H$1:$H$6&"*",A1,1),$I$1:$I$6),"")&IFERROR(LOOKUP(2,SEARCH("*"&SUBSTITUTE($H$1:$H$6,LOOKUP(2,SEARCH("*"&$H$1:$H$6&"*",A1,1),$H$1:$H$6),"§x§")&"*",A1,1),", "&$I$1:$I$6),"")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,660
Messages
6,126,088
Members
449,287
Latest member
lulu840

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