+ Reply to Thread
Results 1 to 6 of 6

vba to search word and extract following 3 words

  1. #1
    Registered User
    Join Date
    11-29-2012
    Location
    Vilnius
    MS-Off Ver
    Excel 2010
    Posts
    8

    vba to search word and extract following 3 words

    Hello,
    Need macros to search certain word (in example "client") in the column and copy to the next column searched word together with following 2 words. Words are separated by space:

    mr dear client tomi mayo kaun
    esti client mako res tuva exco
    ambe acco gir client ingo tes

    Result should be:
    client tomi mayo
    client mako res
    client ingo tes

    Thanks.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: vba to search word and extract following 3 words

    sausis,

    Welcome to the forum! Does it have to be VBA?
    Attached is an example workbook based on the criteria you described.
    In cell B1 is where you type the word to search for, in this case "client"
    Starting in cell A4 and down are the original text strings
    In cell B4 and copied down is this formula:
    Please Login or Register  to view this content.

    That formula provides the correct results. Does that work for you?
    Attached Files Attached Files
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    11-29-2012
    Location
    Vilnius
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: vba to search word and extract following 3 words

    Thank you Tigeravatar,
    I understand that formula is simplier, but in this case I need vba (it is only part of task).
    Sausis

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: vba to search word and extract following 3 words

    sausis,

    Here's a VBA version
    Please Login or Register  to view this content.

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: vba to search word and extract following 3 words

    Condensed version:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-29-2012
    Location
    Vilnius
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: vba to search word and extract following 3 words

    Perfect!
    Thank you Tigeravatar.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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