+ Reply to Thread
Results 1 to 2 of 2

Extract last word from a string and next to last word and so on.

  1. #1
    Registered User
    Join Date
    01-30-2013
    Location
    Norrwalk, CT
    MS-Off Ver
    Excel 2007
    Posts
    1

    Extract last word from a string and next to last word and so on.

    These are two examples of the strings. The back end is consistent. Price is last, Quantity of Contracts is 4th to last, Date is 5th to the last. I need to pull each item seperatley and plug into another location as individual text.

    The beginning portion description can be a various number of words, so need to start at the last.

    3.5% FO Fob Rdam Bgs Oct13 6 Contracts @ 592.00
    3.0% FO GC Mar14 100 Contracts @ 93.75

    Used this Function to get last but can't figure how to get next to last and so on.

    Function ReturnLastWord(The_Text As String)

    Dim stGotIt As String


    stGotIt = StrReverse(The_Text)

    stGotIt = Left(stGotIt, InStr(1, stGotIt, " ", vbTextCompare))



    ReturnLastWord = StrReverse(Trim(stGotIt))

    End Function


    Thanks,
    Jim

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Extract last word from a string and next to last word and so on.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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 word from string
    By sep910 in forum Excel General
    Replies: 3
    Last Post: 09-03-2013, 04:59 AM
  2. Extract Word from String
    By minhestrone in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-21-2013, 11:06 PM
  3. [SOLVED] extract from string whole word(s) containing substring
    By Bearpecs in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-24-2012, 10:37 AM
  4. How do I extract a word from a string?
    By Gabe Tiger in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2006, 10:55 AM

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