Closed Thread
Results 1 to 2 of 2

Extracting the First N Number of Words from a String

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-07-2004
    Posts
    596

    Extracting the First N Number of Words from a String

    Problem:

    Extracting the first three words from each of the strings in column A.

    Solution:
    Use the TRIM, LEFT, FIND, and SUBSTITUTE functions as shown in the following formula:
    =TRIM(LEFT(A2,FIND(\"^\",SUBSTITUTE(TRIM(A2)&\" \",\" \",\"^\",3))-1))

  2. #2
    stephenb
    Guest

    Bug fix


    Good tip but it won't work properly if the text you work on has variable spacing between words. I think you might find the following works better:

    =LEFT(TRIM(A2),FIND("^",SUBSTITUTE(TRIM(A2)&" "," ","^",3))-1)

    Cheers

Closed 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