EXCEL VBA - search for all keywords mentioned in phrase

petrcz

New Member
Joined
Mar 25, 2016
Messages
31
Hello,
I have this set of data:

ABC
1PhrasesKeywordsResult
2cruise from USA to CubaUSAcruise, USA, Cuba
3luxury cruise CubaCubacruise, Cuba
4holiday CubaCruiseCuba


<colgroup><col><col><col><col></colgroup><tbody>
</tbody>

I need function which does this:
- add in column C all keywords from column B which are found in column A. Separate this keywords in column C by comma.

I have this function: =IF(ISNUMBER(SEARCH($B$2;OFFSET(A2;0;0)));$B$2;"")
But do not know, hot to loop it.
I need to check each row in column A againts all keywords in column B.

Thank you in advance for any help.
PR
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
If you have the new TEXTJOIN function that Microsoft added in 2016, then put this formula in C2:

=TEXTJOIN(", ",TRUE,IF(ISNUMBER(SEARCH($B$2:$B$4,A2)),$B$2:$B$4,""))

change the ranges to match your sheet, confirm with Control+Shift+Enter, then drag down the column.

If you don't have TEXTJOIN, then you can either use several work columns to the right (D, E, F, theoretically as many as you have words in column B), or you can use some version of VBA.

Let me know what works for you.
 
Upvote 0

Forum statistics

Threads
1,202,915
Messages
6,052,535
Members
444,590
Latest member
GCLee

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