+ Reply to Thread
Results 1 to 13 of 13

Extract text left and right of character part 2

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    durham
    MS-Off Ver
    Excel 2003
    Posts
    13

    Extract text left and right of character part 2

    With the great help from here we cracked our first nutshell and I tried to use the first solution to overcome my next headache but it doesn't appear to work..

    http://www.excelforum.com/excel-form...character.html

    In essence we are trying to update 5000 templates with a new top and bottom so we thought if we extract the middle then add in the new top and bottom then this should overcome our template headache.

    each template has a set of text characters that define the start and end so we know the bit in the middle is what we need.

    for example.

    <p><!-- ***************************************************************** Put your title in here ********-->
    </p>
    Middle template Info
    <p>
    <!-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ END of description @@@@ --></p>

    So what we tried was to use the previous solution from part 1

    =TRIM(LEFT(SUBSTITUTE(MID(AF19,FIND("|",SUBSTITUTE(AF19,"<!-- ***************************************************************** Put your title in here ********-->","|",1))+1,
    LEN(AF19)),"<!-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ END of description @@@@ -->",REPT(" ",LEN(AF19))),LEN(AF19)))
    But it doesn't seem to work at the front it is catching information prior to the <!-- ***************************************************************** Put your title in here ********-->

    But it does seem to atleast on the small selection were testing on end at the right position.

    <!-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ END of description @@@@ -->

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract text left and right of character part 2

    can you put some samples in an excel workbook and attach that is really hard to read!
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    08-13-2012
    Location
    durham
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Extract text left and right of character part 2

    Sure - lol its hard for you to read my eye's are hurting just looking at a few lines and I've got 5000 to do - lol

  4. #4
    Registered User
    Join Date
    08-13-2012
    Location
    durham
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Extract text left and right of character part 2

    Its a very large file so I'll drop off the unwanted columns and upload a few rows to make it easier.

  5. #5
    Registered User
    Join Date
    08-13-2012
    Location
    durham
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Extract text left and right of character part 2

    See attached a few lines showing on the left the full description and on the right what we had hoped would pull out the element we needed....
    Attached Files Attached Files

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract text left and right of character part 2

    which bit do you need? are they always the same size/structure

  7. #7
    Registered User
    Join Date
    08-13-2012
    Location
    durham
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Extract text left and right of character part 2

    they can be slightly varying in sizes but in essence the bit we need always resides between the two parts that say start and end of description what we are trying to do is to pull the middle bit out so that we put a new top and bottom keeping the middle the same then on mass replace every template in one swoop.

    To try and debug why its not working properly as I mentioned its not catching the beginning section but it is cutting off the lower element at the right position. So I started to breakdown the formula into a step by step process.

    for example.

    =SUBSTITUTE(A2,"<!-- ***************************************************************** Put your title in here ********-->","|",1)
    To me this should look for the given exact text phrase and replace it with a | and only one instance.

    But it doesn't, so if the first function isn't catching the right part of the field its on a loosing streak to start with.

    I can't see why it shouldn't see the texts match, I'm wondering if a format issue is at hand from the orginal .csv file that it came from.
    Last edited by stuartm4h; 07-31-2013 at 05:23 AM.

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract text left and right of character part 2

    ok so far this
    =LEFT(MID(A2,SEARCH("Start of description",A2)+29,255),FIND("</big>",MID(A2,SEARCH("Start of description",A2)+29,255))-1)
    does that get more or less whats needed from a bigger sample? if so then we can work on refining it don't forget the max characters it will return is 255

  9. #9
    Registered User
    Join Date
    08-13-2012
    Location
    durham
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Extract text left and right of character part 2

    Sorry nope it pulled out part but less than the original.

    <center><big> Scale 1:144<br><br>Excellent quality model kit

  10. #10
    Registered User
    Join Date
    08-13-2012
    Location
    durham
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Extract text left and right of character part 2

    This is the bit I'm looking for.....

    <!-- ***************************************************************** Put your title in here ********-->
    </p>
    <center>


    <big> Panavia Tornado 04431 </big> </center>
    </span></big></div>
    </center><p>
    <!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Put your images in here $$$$$ -->
    <big> </big>
    <center><big><br>


    <img src="http://i435.photobucket.com/albums/qq74/gtspeed15/Aircraft/Academy/P1010005-1.jpg"></big></center>




    <hr><br>
    <!-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Start of description @@@@ -->

    <center><big> Scale 1:144<br><br>Excellent quality model kit </big>

    <p><!-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ END of description @@@@ -->

  11. #11
    Registered User
    Join Date
    08-13-2012
    Location
    durham
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Extract text left and right of character part 2

    My fault its a touch ahead of the start description

  12. #12
    Registered User
    Join Date
    08-13-2012
    Location
    durham
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Extract text left and right of character part 2

    So if it pulls everything between.

    <!-- ***************************************************************** Put your title in here ********-->

    down to

    <!-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ END of description @@@@ -->

  13. #13
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract text left and right of character part 2

    ok next punt!
    =SUBSTITUTE(SUBSTITUTE(A2,LEFT(A2,SEARCH("<!-- ***************************************************************** Put your title in here ********-->",A2)-1),""),RIGHT(A2,LEN(A2)-SEARCH("END of description @@@@ ",A2)-26),"")

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Extract text left and right of character
    By stuartm4h in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-12-2013, 07:32 AM
  2. [SOLVED] Extract a part from cell behind a specific character
    By Marco-Kun in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-22-2012, 03:02 PM
  3. Truncating part of string to the left of a character
    By UrbanEast in forum Excel General
    Replies: 4
    Last Post: 12-12-2010, 02:37 AM
  4. Replies: 2
    Last Post: 08-19-2008, 07:18 AM
  5. [SOLVED] Returning left part of cell before a character
    By Alan in forum Excel General
    Replies: 5
    Last Post: 01-23-2005, 04:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1