Search a word in a text string in cells in a table

Nordik

New Member
Joined
Mar 16, 2009
Messages
9
Hi,

Let's say I have a result of a survey, but the answers got mixed up... some cells moved away form their column:

[TABLE="width: 461"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD]Dog[/TD]
[TD]Fish[/TD]
[TD]Cat[/TD]
[/TR]
[TR]
[TD]Bob[/TD]
[TD]I have a dog - blue [/TD]
[TD]I have a fish - yellow[/TD]
[TD]I have a cat - black[/TD]
[/TR]
[TR]
[TD]Carl[/TD]
[TD]I have a cat - grey[/TD]
[TD]I have a dog - red[/TD]
[TD]I have a fish - black[/TD]
[/TR]
[TR]
[TD]John[/TD]
[TD]I have a cat - red[/TD]
[TD]I have a fish - red[/TD]
[TD]I have a dog - green [/TD]
[/TR]
[TR]
[TD]Anna[/TD]
[TD]I have a fish - blue[/TD]
[TD]I have a dog - yellow[/TD]
[TD]I have a cat - white[/TD]
[/TR]
</tbody>[/TABLE]

I tried to sort this by using FIND, MATCH, INDEX but I seems I cannot make my formula work. For each line, I was trying to find "dog" for example and then display in a new column the content of cell in which "dog" is found. The final result I am looking for is:

[TABLE="width: 459"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD]Dog[/TD]
[TD]Fish[/TD]
[TD]Cat[/TD]
[/TR]
[TR]
[TD]Bob[/TD]
[TD]I have a dog - blue [/TD]
[TD]I have a fish -yellow[/TD]
[TD]I have a cat - black[/TD]
[/TR]
[TR]
[TD]Carl[/TD]
[TD]I have a dog - red[/TD]
[TD]I have a fish - black[/TD]
[TD]I have a cat - grey[/TD]
[/TR]
[TR]
[TD]John[/TD]
[TD]I have a dog - green [/TD]
[TD]I have a fish - red[/TD]
[TD]I have a cat - red[/TD]
[/TR]
[TR]
[TD]Anna[/TD]
[TD]I have a dog - yellow[/TD]
[TD]I have a fish - blue[/TD]
[TD]I have a cat - white[/TD]
[/TR]
</tbody>[/TABLE]

I don't need a formula to sort the whole table at once, I can do column by column/several steps.


Any help please?

Thanks in advance.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Give this formula a try (put it in e2 and copy it right to G2 and down as long as required):

=INDEX($B2:$D2,MATCH("*"&B$1&"*",$B2:$D2,0))
Excel Workbook
ABCDEFG
1dogfishcatdogfishcat
2BobI have a dog - blueI have a fish - yellowI have a cat - blackI have a dog - blueI have a fish - yellowI have a cat - black
3CarlI have a cat - greyI have a dog - redI have a fish - blackI have a dog - redI have a fish - blackI have a cat - grey
4JohnI have a cat - redI have a fish - redI have a dog - greenI have a dog - greenI have a fish - redI have a cat - red
5AnnaI have a fish - blueI have a dog - yellowI have a cat - whiteI have a dog - yellowI have a fish - blueI have a cat - white
Sheet
 
Upvote 0
Thanks to both of you.
Your solutions are working like a charm :)

=IF(IFERROR(FIND(LOWER(B$1);$B2);0);$B2;IF(IFERROR(FIND(LOWER(B$1);$C2);0);$C2;IF(IFERROR(FIND(LOWER(B$1);$D2);0);$D2;0)))

=INDEX($B2:$D2;MATCH("*"&B$1&"*";$B2:$D2;0))

I will go with István's formula as it was the one I tried to create. I wasn't using the * and the & in the correct way.

Thanks again :)

 
Upvote 0

Forum statistics

Threads
1,224,427
Messages
6,178,585
Members
452,859
Latest member
dallasazcat

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