Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 177
Default extract text between 2 tags

Cell A1 contains the text below.

In Cell B1, how do extract all the text between <status and </status so it
returns "error"

another example, how do I extract all the text between <comment and
</comment?

generally, how do I extract text that lies between 2 tags?

thanks a lot...



<apple2
<statuserror</status
<ack</ack
<errortypeCan't enter BTC - Not currently short</errortype
<comment<![CDATA[You can't enter an order to Buy To Close (BTC) because
you do not have a short position in BHP.
If you want to enter a BTC, make it conditional on a
not-yet-executed STO order. ]]</comment
</apple2


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default extract text between 2 tags

I believe this will work:

=LEFT(MID(A2,FIND("<status",A2)+LEN("<status"),9 99),FIND("</status",MID(A2,FIND("<status",A2)+LEN("<status" ),999))-1)

You can replace the "<status" & "</status" with other texts, if deisred,
or simply change them to a cell reference.
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"SteveC" wrote:

Cell A1 contains the text below.

In Cell B1, how do extract all the text between <status and </status so it
returns "error"

another example, how do I extract all the text between <comment and
</comment?

generally, how do I extract text that lies between 2 tags?

thanks a lot...



<apple2
<statuserror</status
<ack</ack
<errortypeCan't enter BTC - Not currently short</errortype
<comment<![CDATA[You can't enter an order to Buy To Close (BTC) because
you do not have a short position in BHP.
If you want to enter a BTC, make it conditional on a
not-yet-executed STO order. ]]</comment
</apple2


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 177
Default extract text between 2 tags

thanks works great!

"Luke M" wrote:

I believe this will work:

=LEFT(MID(A2,FIND("<status",A2)+LEN("<status"),9 99),FIND("</status",MID(A2,FIND("<status",A2)+LEN("<status" ),999))-1)

You can replace the "<status" & "</status" with other texts, if deisred,
or simply change them to a cell reference.
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"SteveC" wrote:

Cell A1 contains the text below.

In Cell B1, how do extract all the text between <status and </status so it
returns "error"

another example, how do I extract all the text between <comment and
</comment?

generally, how do I extract text that lies between 2 tags?

thanks a lot...



<apple2
<statuserror</status
<ack</ack
<errortypeCan't enter BTC - Not currently short</errortype
<comment<![CDATA[You can't enter an order to Buy To Close (BTC) because
you do not have a short position in BHP.
If you want to enter a BTC, make it conditional on a
not-yet-executed STO order. ]]</comment
</apple2


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate html Tags from Excel formatted text Bikram Excel Discussion (Misc queries) 0 February 24th 09 07:05 AM
Need to extract certain text from text string Trista @ Pacific Excel Worksheet Functions 4 November 21st 07 07:07 PM
Extract text from large Text ldiaz Excel Discussion (Misc queries) 4 November 14th 07 01:21 AM
Text Extract Arturo Excel Worksheet Functions 1 December 12th 05 04:24 PM
EXTRACT TEXT FROM TEXT STRING carricka Excel Worksheet Functions 4 July 8th 05 11:00 AM


All times are GMT +1. The time now is 04:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"