Extracting numbers related to certain keywords from alphanumeric strings

kurtgarb798

New Member
Joined
Mar 5, 2009
Messages
6
Hi,

I'm a postgraduate student at Durham University in the United Kingdom and my research is on media coverage and humanitarian assistance of Natural Hazards and is heavily Excel-based but myself and my supervisors seem to have come to a brick wall and no one in my whole department know what to do.

We are looking for a function or formula that can return a number from an alphanumeric string that relates to a keyword in that string.

I shall explain...

We have one column that looks like:

7 Vietnamese women die in quarry collapse--officials - Inquirer.net
1 dead, 1 missing as avalanches hit stormy California - San Diego Union Tribune
1 person dead, 1 missing skier found in SoCal avalanche - San Jose Mercury News
Landslide kills 7 on Indonesia's Java - Reuters UK

And we need a column that shows only the number which relates to fatalities mentioned in each title.

I have managed to find a way of extracting the numbers from the alphanumeric strings but we have problems with titles like this:

Mingo National Wildlife Refuge Going Through "100 Year Flood" - KFVS

So we are looking for a way to extract numbers from the strings that contain keywords like "dead" "deaths" "fatalities" etc.

We are also looking for a way to extract the last part of the above strings:

- KFVS
- Reuters UK
- San Jose Mercury News

and then automatically assign abbreviated codes and country names to the news agency specified.

The final database should look something like this:

"Landslide kills 7 on Indonesia's Java - Reuters UK" - Reuters - UK - REU - UK - 7

No one in my entire university can figure this out.

Pleas Help!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
What I would do (as long as you already know how to extract numbers from text) is the following.

First test the string if it contains one of your keywords ( if there are to many, i would put them into an array).

I quickly tested the below, by "uppercasing (UCASE)" the string first you make it case insensitive if you write your keywords in uppercase.

Code:
Sub testing1()

For Each c In Range("E1:E50")

If UCase(c.Value) Like "*DIE*" Or UCase(c.Value) Like "*FATAL*" Then

MsgBox c.Address & " contains a key-value"
'your code to extract the numbers go here

Else
End If

Next c


End Sub

Excel Workbook
E
5
67 Vietnamese women die in quarry collapse--officials - Inquirer.net
71 dead, 1 missing as avalanches hit stormy California - San Diego Union Tribune
81 person dead, 1 missing skier found in SoCal avalanche - San Jose Mercury News
9Landslide kills 7 on Indonesia's Java - Reuters UK
10
11
Sheet4
 
Upvote 0
If you like, send me the file (use the link just below here) and i´ll try to help you along
Assuming you use formulas and no macro´s (yet?) the code I posted is a macro.
 
Upvote 0

Forum statistics

Threads
1,214,661
Messages
6,120,790
Members
448,994
Latest member
rohitsomani

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