Sort a table by key words in a column.

hotrod

Board Regular
Joined
Feb 3, 2009
Messages
103
Table, A1/H1 - A100/H100.
Column H rows have a lot of text and I want to sort the table by a key word ( blue, red and green) within the text of each row.
Is it possible?

Or what about a formula for column I that searches column H for the key words ( blue, red and green) and puts in the key word for each row.
Then I could sort the table by I column.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
You could put this in I1 and then copy down:

=LOOKUP(H1, {"blue","green","red"}, {1,3,2})


Notice the arrays are alphabetic? Anyway, now you can sort by column I and all the 1s will be on top, etc...
 
Upvote 0
The second approach is certainly doable.

For example
Code:
=IF(ISERROR(FIND("blue",A1,1)),IF(ISERROR(FIND("red",A1,1)),
IF(ISERROR(FIND("green",A1,1)),"NONE","GREEN"),"RED"),"BLUE")

This may not deal with multiple entries exactly as you wish, for example where A1 contains "RED BLUE GREEN". If this is a possibility, please give more details on how you want to handle it.
 
Upvote 0
=LOOKUP(H1, {"blue","green","red"}, {1,3,2})

=IF(ISERROR(FIND("blue",A1,1)),IF(ISERROR(FIND("red",A1,1)), IF(ISERROR(FIND("green",A1,1)),"NONE","GREEN"),"RED"),"BLUE")

Both formulas only work when blue, green or red is in a cell.

Does not work if blue, green or red is in a sentenance and this is what I need.
 
Upvote 0
...Does not work if blue, green or red is in a sentenance and this is what I need.

That's an important distinction you left out of your original question. Best be more complete next time, a lot time gets wasted with omissions like that.

Setup your text strings in a column, the values to return in the next column...like this example...it's an ARRAY-ENTERED formula so you have to press CTRL-SHIFT-ENTER to confirm it, not just ENTER.

Excel Workbook
HIJKLMN
1The dog is green3blue1
2That red bird.2red2
3The brown lizard0green3
4The sky is blue1
Sheet2
 
Upvote 0
Try..

=LOOKUP(9.99999999999999E+307,FIND({"$$$","blue","red","green"},"$$$"&A1),{"None","blue","red","green"})

Hope this helps
 
Upvote 0
=IF(ISERROR(FIND("blue",A1,1)),IF(ISERROR(FIND("red",A1,1)), IF(ISERROR(FIND("green",A1,1)),"NONE","GREEN"),"RED"),"BLUE")

Both formulas only work when blue, green or red is in a cell.

Does not work if blue, green or red is in a sentenance and this is what I need.

Not correct.

My formula works if blue, green or red is in a sentence.
For example, if A1 contains
"The sky is blue today"
my formula returns BLUE
 
Upvote 0
Gerald, tried formula again and it does work. I must have had A1 when it should have been H1. Thanks for making me try again.

Facethegod, this formula also works, thank you.

jbeaucaire, sorry for waisting your time, thanks for your efforts.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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