+ Reply to Thread
Results 1 to 5 of 5

Return all, after/before certain word.

  1. #1
    Registered User
    Join Date
    09-16-2008
    Location
    Michigan
    Posts
    4

    Return all, after/before certain word.

    I can use this function:

    =RIGHT(A1,LEN(A1)-FIND(" ",A1,1))

    to remove all but the first word in a string, but need to be able to broaden the range.



    For example, say I have the following text in A1:

    "This is the text I need to edit, with the word slinky being the common value."

    I need to be able to take a common value in a text area (in this case that common being "slinky") and remove everything before that word as well as the word itself. I also need to be able to do the same thing, and have a formula to remove everything AFTER a common value.

    "being the common value."

    or

    "This is the text I need to edit, with the word"


    Not sure if its possible to also setup a formula to eliminate text between 2 common values? For instance, being able to remove everything between "[" and "]" in the following:

    "This is the text I [need to edit, with the word] slinky being the common value."

    Which would return:

    "This is the text I slinky being the common value."


    Thanks in advance for any assistance!!!

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    If text to find, e.g. "slinky" is in B1 try this formua for all before

    =TRIM(LEFT(A1,SEARCH(B1,A1)-1))

    and for after

    =TRIM(REPLACE(A1,1,SEARCH(B1,A1)-1+LEN(B1),""))

  3. #3
    Registered User
    Join Date
    09-16-2008
    Location
    Michigan
    Posts
    4
    Thanks daddylonglegs!

    That is a perfect solution for the first two examples. Do you have any idea if the last example with a range is possible?

    Thanks again!

  4. #4
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Wouldn't you just join the results of the formulas given for that like:

    =TRIM(LEFT(A1,SEARCH(B1,A1)-1) & REPLACE(A1,1,SEARCH(B1,A1)-1+LEN(B1),""))

    Richard
    Richard Schollar
    Microsoft MVP - Excel

  5. #5
    Registered User
    Join Date
    09-16-2008
    Location
    Michigan
    Posts
    4
    Absolutely. I guess I should think before I talk!

    Thanks for the assistance.

+ 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. Pasting Cells from Excel into a Word Table
    By Wibs in forum Excel General
    Replies: 6
    Last Post: 05-30-2012, 08:08 AM
  2. Code to find a specific word???
    By arfanvilla in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-07-2008, 08:44 AM
  3. IF condition to return 3 variants
    By Marie1uk in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-06-2007, 04:56 PM
  4. Return latest word in a row.
    By Lund-Nielsen in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-31-2007, 03:46 AM
  5. linking excel workbooks to Word document
    By Pooders in forum Excel General
    Replies: 0
    Last Post: 05-07-2007, 10:57 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