+ Reply to Thread
Results 1 to 4 of 4

Finding and Pulling Text Mid String

  1. #1
    Registered User
    Join Date
    03-11-2014
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    2

    Finding and Pulling Text Mid String

    Hey guys, I promised I searched around these forums for quite some time before posting, so sorry if this was repeated somewhere.

    Right now I have a program that is exporting emails from my Outlook to Excel, specifically a 'Subject' and 'Body'. Each goes into its own cell, so the 'Subject' of the email is in 'A#' while the 'Body' is in the corresponding 'B#' cell.

    Pretty straightforward so far. Now the body that is being exported is an automatic email with 150-250 characters. Each email is different, different wording, but they all share the same constant where there is a string of text "Shipped By: CARRIER_NAME" and "Tracking No: ##########". Example:

    "-----Original Message-----
    Sent: Tuesday, March 11, 2014 12:24 AM
    Subject: FW: Your order has shipped (######)


    -----Original Message-----
    Sent: Tuesday, March 11, 2014 4:12 AM
    Subject: Your order has shipped (######)

    We thought you'd like to know that we completed and shipped your
    Multi-Channel Fulfilment Order () to one of your customers:

    You can track the status of this order by visiting Seller Central at:
    https://

    The following items have been shipped by
    --------------------------------------------------------------------------
    Qty Item
    --------------------------------------------------------------------------
    Shipped By: CARRIER_NAME Tracking No: 111111111111111
    --------------------------------------------------------------------------

    As stated on our Web site, there is no weekend service for our Next Day
    delivery option (Express Delivery). Therefore, a package that leaves our
    fulfilment centre on a Saturday or Sunday does not actually reach the
    carrier until Monday morning.
    --------------------------------------------------------------------------
    Please note: this email was sent from a notification-only address that
    cannot accept incoming e-mail. Please do not reply to this message.


    ----------------------------------------------------------------------------
    --
    ----------------------------------------------------------------------------
    --"

    What I need is to pull out the CARRIER_NAME and TRACKING NO into their own cells. Now, the carrier name will usually be one of four different carriers so they all have different character lengths. While tracking ranges drastically in which it may be alphanumeric or simply numeric. I've been playing around with "=MID" and "FIND" functions, but I'm striking out hard. If any one has any suggestions, it would be much appreciated!

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Finding and Pulling Text Mid String

    You may try:
    C2: =SEARCH("Shipped By:",B2)+11
    D2:=SEARCH("Tracking No:",B2,C2)
    E2: =TRIM(MID(B2,C2,D2-C2))
    F2: =TRIM(MID(B2,D2+13,SEARCH("-",B2,D2)-D2-13))
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Registered User
    Join Date
    03-11-2014
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    2

    Re: Finding and Pulling Text Mid String

    Fantastic! Totally worked

    What exactly is taking place here, I guess I'm lacking in knowledge much more than I thought?

  4. #4
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Finding and Pulling Text Mid String

    C2 finds position of "Shipped By:" in B2 (and adds 11 which is length of this text)
    D2 finds position of "Tracking No:" after match in C2
    E2 finds text in between these positions (TRIM will remove any extra spaces)
    F2 takes text after D2 position up to first "-" character.

    Is clear now?

+ 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] Pulling numbers out of text string
    By snoopy1461 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-27-2013, 12:17 PM
  2. Replies: 2
    Last Post: 07-02-2013, 11:35 AM
  3. [SOLVED] Pulling a string of text
    By Montoro22 in forum Excel General
    Replies: 5
    Last Post: 06-11-2013, 11:36 AM
  4. [SOLVED] pulling text from the middle of a string
    By DRFILL in forum Excel General
    Replies: 3
    Last Post: 09-21-2012, 11:35 AM
  5. [SOLVED] Pulling specific text string from a cell
    By smtwidle in forum Excel General
    Replies: 6
    Last Post: 06-25-2012, 03:28 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