+ Reply to Thread
Results 1 to 5 of 5

How to extract a piece of a string variable, and assign to a new variable

  1. #1
    Registered User
    Join Date
    10-02-2015
    Location
    Pennsylvania
    MS-Off Ver
    2007
    Posts
    33

    Question How to extract a piece of a string variable, and assign to a new variable

    Hi All,

    Hopefully this is an easy one...

    If I have a string:

    strEmailBody="Percent done and comments: 99% (Will be done tonight!)<end-of-line>etc...additional text is on the next line in this same string"

    Would anyone know how to extract any text between "comments: " and the (unseen) end-of-line character?
    ...it would be assigned to a new string called "strPctDoneAndComments"

    Thanks so much,
    jmc
    Last edited by jmccoughlin; 11-04-2015 at 10:20 PM.

  2. #2
    Forum Contributor Obsessed's Avatar
    Join Date
    05-22-2013
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 365
    Posts
    215

    Re: How to extract a piece of a string variable, and assign to a new variable

    I would assume that you'd already have that string elsewhere, else how did you build the email body string?
    Want to show appreciation for the help you received from a member? Give them reps by clicking the bottom left of their post!

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How to extract a piece of a string variable, and assign to a new variable

    Try something like this.
    < br> is a common end-of-line HTML tag.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    10-02-2015
    Location
    Pennsylvania
    MS-Off Ver
    2007
    Posts
    33

    Re: How to extract a piece of a string variable, and assign to a new variable

    Thanks so much AlphaFrog!

    This worked great!

    I had to make a slight tweak by replacing <br> with vbLf, other than that... perfect! Thanks again!!

    To Obsessed, the string is read from the body string from an Outlook email. I should have mentioned that above, but thankfully, all figured out!

  5. #5
    Registered User
    Join Date
    07-18-2014
    Location
    USA
    MS-Off Ver
    2013
    Posts
    36

    Re: How to extract a piece of a string variable, and assign to a new variable

    Try this
    Please Login or Register  to view this content.

+ 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 variable length string
    By mintymike in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-10-2015, 12:01 PM
  2. [SOLVED] How can I assign the last 4 characters of a string to a string variable?
    By dschmitt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-29-2015, 01:41 AM
  3. [SOLVED] UDF to extract digits from variable range string
    By Excel2010101 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 04-28-2014, 03:41 PM
  4. [SOLVED] how to extract variable length string
    By isurunk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-11-2014, 01:13 AM
  5. [SOLVED] Assign entire row to variable, how do you paste variable values in a new workbook?
    By tv69 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2013, 08:01 PM
  6. Replies: 4
    Last Post: 07-12-2013, 12:14 PM
  7. Assign activesheet name to string variable?
    By MickeyGreen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2007, 12:08 PM

Tags for this Thread

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