Search for a single word in a sentence and output the searched value next to the correct sentence.

Flambo

New Member
Joined
May 14, 2015
Messages
5
Hi there, first post.

I'm knees deep in excel these days, but unfortunately not overtly talented (yet).

I have the following issue:

Two columns:

A = one with a set of 1500 keywords
B = 25000 sentences of text
C = the output (which should also be the keyword)

I need to search the sentences for the keywords and next to the sentence output the value that was searched in column C.

I'm currently trying to use Vlookup with a search function inside the formula but I'm not getting very far unfortunately.

Here is an image, should be simple enough

excel.png




Many thanks,

Peter
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
excel2.png



Thank you, I'm sure there is a reasonably simple solution, but its beyond me!

Thanks again.

A = The search terms
B = Sentences to be searched
C = would be where the formula/ output
 
Upvote 0
hum.....think you need VBA on this....and i'm not the right guy to give a solution...
Let some VBA guru check on this...
 
Upvote 0
So, still hoping for a solution if anyone has any ideas... you'll be saving me days and days of work!
 
Upvote 0
Try this, I use it to extract keywords on a file with thousands of records and it works just fine.

Code:
{=IFERROR(VLOOKUP(INDEX(kSearchs,MATCH(SMALL(IFERROR(SEARCH(kSearchs,B2),""),1),SEARCH(kSearchs,B2),0)),kSearchs,1,FALSE),"No matches found")}

Where kSearchs is a named range containing the your keywords list. I use a dynamic range so whenever I want to add keywords I just type them at the bottom of the list and the range adjust by itself, but you are OK using a fixed named range; if you don't want to use a named range just use the actual range on your formula.

If no keyword is found the formula will output "No matches found" but you can change this to whatever you want, even an empty string ("") to leave teh cell blank.

IMPORTANT! Remember this is an array formula, don't type the brackets around it, instead hod down Ctrl & Shift and then press Enter on C2. Once you enter the first formula just drag down and Excel will fill the rest of the cells.

Saludos!
 
Upvote 0
I forgot to mention, to find more than one keyword you will need to use other instances of the formula, changing the index on the SMALL function to 2, 3, etc. I have used it with up to 4 instances with good results. To show them separated by comas you will need to joint your instances of the formula like this =Formula1&", "&Forumla2&", ".... Formula#

A word on Array formulas: When using this type of formulas on large data bases, the excel engine has to process tons of data and it may take a few seconds to run. It doesn's bother me because I run it once a day, but if you are using this functionality on acontinuos way it might be better to look int a VBA approach.

Saludos!
 
Upvote 0
You're welcome!

I was on your same situation a few months ago until I came up with this solution. But I'm pretty sure that extra time you'll gain won't last long LOL
 
Upvote 0

Forum statistics

Threads
1,214,413
Messages
6,119,374
Members
448,888
Latest member
Arle8907

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