+ Reply to Thread
Results 1 to 6 of 6

How to extract a substrings if length is not known

  1. #1
    Registered User
    Join Date
    07-30-2014
    Location
    Erlangen, Germany
    MS-Off Ver
    2010 :-(
    Posts
    3

    How to extract a substrings if length is not known

    Hi Gang,
    I have to deal with a lot of xml report files that all have a header string and my problem is how to parse the string for the nuggets i require for my macro.
    This is a sample string:
    <Function IDREF="TST_RxRccsMatrix_Rx64" Start="2011-04-07T14:21:35.593000+02:00" Status="Success" Tags="SystemSerialNumber:41009" End="2011-04-07T14:29:16.625000+02:00">

    I need to extract
    - the report type: TST_RxRccsMatrix (length of this string is not constant)
    - the start date-time stamp: 2011-04-07T14:21:35.593000+02:00 (length is constant)
    - the serial number: 41009 (length is constant)

    I have found methods using Split, InStr and Left but none produce the desired results for all three extractions. The one stumping me is the report type.

    I truely appreciate any help on this!

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,957

    Re: How to extract a substrings if length is not known

    I know this is not VBA, it is a regular formula, but maybe you can work around it?

    =MID(A1,FIND("""",A1,1)+1,FIND("""",A1,FIND("""",A1,1)+1)-FIND("""",A1,1)-1)
    This will give you TST_RxRccsMatrix_Rx64
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: How to extract a substrings if length is not known


    Hi,

    see also InStrRev and Mid functions …

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,883

    Re: How to extract a substrings if length is not known

    Try:
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: How to extract a substrings if length is not known

    Hi..

    Can you attach a Workbook with a lot more sample strings.. the more the better so i can see any patterns that exist..

    Edit: oops.. I am way to slow in refreshing.. but still attach a Workbook if you like for a VBA solution..

    Try this.. assuming your data is in column A.. and you want the results in B,C and D..

    Please Login or Register  to view this content.
    Last edited by apo; 10-11-2014 at 07:51 PM. Reason: Fixed up a mistake..

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,558

    Re: How to extract a substrings if length is not known

    Another one to try (on a copy of your Workbook)
    Is there any constant in IDFEF? Maybe Rx64" or the amount of characters in _Rx64" (6 incl underscore) or the word Matrix?

    Please Login or Register  to view this content.
    Note: apo comes up with some fantastic stuff.

+ 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] how to extract variable length string
    By isurunk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-11-2014, 01:13 AM
  2. [SOLVED] Extract substrings from variable strings
    By WmBarth in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-13-2014, 06:10 AM
  3. [SOLVED] Help needed on how to extract substrings from comma delimited text
    By kknb0800 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-18-2013, 03:18 PM
  4. Replies: 3
    Last Post: 11-21-2012, 03:28 PM
  5. [SOLVED] Extract Substring, then Ignore that Substring, while collecting data from Other substrings
    By Sameki121 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-17-2012, 05:21 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