+ Reply to Thread
Results 1 to 5 of 5

Extract words from cells and IF statement

Hybrid View

pomper Extract words from cells and... 03-14-2015, 02:10 PM
bebo021999 Re: Extract words from cells... 03-14-2015, 02:19 PM
Richard Buttrey Re: Extract words from cells... 03-14-2015, 02:19 PM
AlKey Re: Extract words from cells... 03-14-2015, 02:22 PM
MarvinP Re: Extract words from cells... 03-14-2015, 02:23 PM
  1. #1
    Registered User
    Join Date
    02-06-2015
    Location
    London,England
    MS-Off Ver
    Excel 2010
    Posts
    34

    Extract words from cells and IF statement

    Hi,

    I extract first 7 words from every cell using following formula:
    =LEFT(A1,FIND("@@",SUBSTITUTE(A1," ","@@",7),1)-1)
    It works but when I have cells with words less than 7 I got #VALUE! error.
    How can I write IF statement that if cells has less than 7 words, cell will be just copied to new cell.

    columna A                                                       Column B
    dad sddas sadsa dasdas ddadd sd 7 sddasd          dad sddas sadsa dasdas ddadd sd 7     
    dasdas dsda sddas                                           dasdas dsda sddas

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,645

    Re: Extract words from cells and IF statement

    Try to add more spaces into text cell (i.e : 7) to get unique text with at least 7 spaces:

    =LEFT(A1,FIND("@@",SUBSTITUTE(A1&REPT(" ",7)," ","@@",7),1)-1)
    Quang PT

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Extract words from cells and IF statement

    Hi,

    Just wrap your formula in an IFERROR() function. i.e

    =IFERROR(LEFT(A1,FIND("@@",SUBSTITUTE(A1," ","@@",7),1)-1),A1)
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extract words from cells and IF statement

    Try this

    =TRIM(LEFT(SUBSTITUTE(A1," ",REPT(" ",125)),125*7))
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,251

    Re: Extract words from cells and IF statement

    Hi pomper,

    Try this formula instead in B2 when your long strings are in A2.

    =TRIM(LEFT(SUBSTITUTE(A2," ",REPT(" ",LEN(A2))),7*LEN(A2)))
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

+ 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] How can I extract first words from cells.
    By pomper in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-14-2015, 01:02 AM
  2. [SOLVED] Extract words from cells into a new cell
    By soli004 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-16-2014, 08:41 AM
  3. Extract words from cells containing text
    By Pelona in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-02-2013, 05:17 PM
  4. Replies: 6
    Last Post: 04-25-2012, 08:12 PM
  5. Extract specific words from cells
    By Santa-D in forum Excel General
    Replies: 6
    Last Post: 06-18-2006, 11:10 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