Extract substring from text string folllowing keyword - formula required

steallan

Active Member
Joined
Oct 20, 2004
Messages
308
Hi - hoping some expert can help me with a text search query

I've got a column full of text entries. What I would like to do is extract x number of characters after certain keywords.

So for example.

keyword 'DOB: ' then bring back the next 10 characters

So if the below is the text in cell AP2 -

"blah blah blah DOB: 1982-11-32 Name: Sir Billy Weesle Major turn ons: women dressed as Rabbits, GoT blah blah blah"

- I am after a formula I can put in another cell that would find 'DOB: ' and then return the next 10 characters, so i'd get back 1982-11-32

Some formula that works I can then use in other cells to find other keywords and return other values.

Any help would be greatly appreciated.

Thanks

Ste
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
How about
=MID(A2,SEARCH("dob:",A2)+5,10)
 
Upvote 0
with PowerQuery (Get&Transform)

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]raw[/td][td][/td][td=bgcolor:#70AD47]raw[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]blah blah blah DOB: 1982-11-32 Name: Sir Billy Weesle Major turn ons: women dressed as Rabbits, GoT blah blah blah[/td][td][/td][td=bgcolor:#E2EFDA]1982-11-32[/td][/tr]
[/table]


Code:
[SIZE=1]// Table23
let
    Source = Excel.CurrentWorkbook(){[Name="Table23"]}[Content],
    ExtractAfter = Table.TransformColumns(Source, {{"raw", each Text.AfterDelimiter(_, "DOB: "), type text}}),
    Extract10 = Table.TransformColumns(ExtractAfter, {{"raw", each Text.Start(_, 10), type text}})
in
    Extract10[/SIZE]
 
Upvote 0
Yep that works, and I even understand it, which is double good.

Thank you good Sir. You are a star.
 
Upvote 0
Thanks also Sandy666 I shall look at your solution as well, also will probably teach me something,

xx
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

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