+ Reply to Thread
Results 1 to 12 of 12

=LEFT to retrun values by word count?

  1. #1
    Registered User
    Join Date
    09-11-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    53

    =LEFT to retrun values by word count?

    Hi

    I have a spreadsheet which is being used for a wordpress import. it needs to import a custom excerpt which is limited by word count. Hence, I need to do an =LEFT statement which returns a cell's contents by word count rather than character count. Is this possible?

    Regards

    Matt

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: =LEFT to retrun values by word count?

    You can count the spaces by comparing the length of the cell to the length of the cell without spaces. And you can use SUBSTITUTE to remove the spaces to facilitate the comparison.

    Suggest you post a sample workbook.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    09-11-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: =LEFT to retrun values by word count?

    I've attached an example

    Any help would be greatly appreciated

    Cheers
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: =LEFT to retrun values by word count?

    in D3 try below
    =LEFT(A3,FIND("@",SUBSTITUTE(A3," ","@",C3))-1)


    in above function substitute will give "@" at 25th space and then find will find the location of 25th space which is 306 in your attachment now -1 of it is 305 and then left will take words
    Last edited by hemesh; 01-29-2016 at 05:44 AM. Reason: edited by mistake
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  5. #5
    Registered User
    Join Date
    09-11-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: =LEFT to retrun values by word count?

    Many thanks hemesh that works for most of my data. The only exception being when my main posts are exactly 25 words long is returns '#VALUE!'

  6. #6
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: =LEFT to retrun values by word count?

    in that case use below formula I think this will suffice for all your need
    =IF(C3>25,LEFT(A3,FIND("@",SUBSTITUTE(A3," ","@",C3))-1),LEFT(A3,FIND("@",SUBSTITUTE(A3&" "," ","@",C3))-1))
    Last edited by hemesh; 01-29-2016 at 05:44 AM. Reason: updated formula

  7. #7
    Registered User
    Join Date
    09-11-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: =LEFT to retrun values by word count?

    Thanks again, were getting there. Apologies I should have said any posts of 25 words or less...because with your new formula, this now just leaves posts that are under 25 words with an error.

  8. #8
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: =LEFT to retrun values by word count?

    check i have updated formula above

  9. #9
    Registered User
    Join Date
    09-11-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: =LEFT to retrun values by word count?

    There still seems to be a problem with all under 25

    I have attached updated spreadsheet with your new formula and 3 examples over 25, exactly 25 and 25
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: =LEFT to retrun values by word count?

    @ Matt in that case
    =IF(B3>C3,LEFT(A3,FIND("@",SUBSTITUTE(A3," ","@",C3))-1),A3)

    above formula will check the word count and word count limit if word count is greater than limit that time it will take the data from the left upto word limit if it is less than that or equals to word limit than data from the whole cell will be taken is it what you are looking for

  11. #11
    Registered User
    Join Date
    09-11-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: =LEFT to retrun values by word count?

    You've cracked it

    Many thanks for your help

  12. #12
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: =LEFT to retrun values by word count?

    @ matt you are welcome ! and thanks for the feedback.

    I would appreciate if you click bottom left corner of the post of all who helps you at this forum, this add to the reputation of users that can be seen in the form of green bar at the bottom of their name.

+ 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. Sum values if left column has certain word criteria
    By only1abhi in forum Excel General
    Replies: 3
    Last Post: 01-26-2015, 09:35 AM
  2. Retrun headers of large values in range
    By fluters1243 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-26-2014, 05:11 PM
  3. [SOLVED] Find word in text string and return word adjacent to the left
    By eadamquinn in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-06-2014, 03:22 PM
  4. [SOLVED] Excel - Get the Word to the Left or Right of Another Word (text string)
    By sweetrevelation in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-22-2013, 01:36 PM
  5. [SOLVED] find word in string, count how many special characters are to its left
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2013, 06:46 PM
  6. Replies: 1
    Last Post: 12-03-2012, 08:14 AM
  7. How to Sort Columns by Left-to-Right by WORD count
    By thetartan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2012, 02:52 PM

Tags for this Thread

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