ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Extract text within two specific values within a cell (https://www.excelbanter.com/excel-worksheet-functions/220395-extract-text-within-two-specific-values-within-cell.html)

michelle

Extract text within two specific values within a cell
 
I have a cell (D2) of wrapped text that contains two keywords: "NAME:" and
"CONSTRAINED". I want to extract all of the text between these two keywords
and paste it in cell L2.
I'm getting closer by using

=MID(D2,SEARCH("NAME:",D2),30)

to get the text that follows the first keyword "NAME:", but I am stuck now
trying to determine how to get the extraction to stop when the query reaches
the second keyword "CONSTRAINED".

Your help would be much appreciated

Ron Rosenfeld

Extract text within two specific values within a cell
 
On Wed, 11 Feb 2009 08:30:03 -0800, Michelle
wrote:

I have a cell (D2) of wrapped text that contains two keywords: "NAME:" and
"CONSTRAINED". I want to extract all of the text between these two keywords
and paste it in cell L2.
I'm getting closer by using

=MID(D2,SEARCH("NAME:",D2),30)

to get the text that follows the first keyword "NAME:", but I am stuck now
trying to determine how to get the extraction to stop when the query reaches
the second keyword "CONSTRAINED".

Your help would be much appreciated


Search for "CONSTRAINED" and subtract from that your initial SEARCH to get the
Number of letters.

Note that your above formula will also extract the word NAME: which is not
'between'.

Something like:

=MID(D2,SEARCH("NAME:",D2)+6,SEARCH("CONSTRAINED", D2)-SEARCH("NAME:",D2)-7)

will obtain the characters between the keywords. You need to also decide what
you want to do about leading/trailing spaces and any included LineFeeds.
--ron


All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com