+ Reply to Thread
Results 1 to 14 of 14

Extract text to left of numer

  1. #1
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Extract text to left of numer

    Hi there, I need some code that will extract the text ONLY from a string. The problem is the number in the string isn't stored as a number (as its part of a string).

    Below are some examples

    Lord Brantwood 3/1 (I need Lord Brantwood)
    Running Wolf 120/1 (I need Running Wolf)
    Majestic Sun 5/2 (I need Majestic Sun)

    Thanks in advance

  2. #2
    Valued Forum Contributor
    Join Date
    07-07-2014
    Location
    Washington DC
    MS-Off Ver
    2007
    Posts
    1,047

    Re: Extract text to left of numer

    Will it always be 2 words that you want to extract? If so, try this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Extract text to left of numer

    No, it could be 1 to 5 words

  4. #4
    Valued Forum Contributor
    Join Date
    07-07-2014
    Location
    Washington DC
    MS-Off Ver
    2007
    Posts
    1,047

    Re: Extract text to left of numer

    Well then just add a helper Column to calculate the number of words in the cell:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then, assuming the helper column is B1, you would update the formula to reference it as follows:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Extract text to left of numer

    Thats a great solution. Many thanks

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Extract text to left of numer

    Hopefully someone else will come up with something more eligant, but this brute-force effort works without a helper...

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,293

    Re: Extract text to left of numer

    Please Login or Register  to view this content.
    Does this work?
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  8. #8
    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 text to left of numer

    Maybe this

    =SUBSTITUTE(A1,MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&1234567890)),FIND("(",A1)-MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&1234567890))),"")

    Row\Col
    A
    B
    1
    Lord Brantwood 3/1 (I need Lord Brantwood) Lord Brantwood (I need Lord Brantwood)
    2
    Running Wolf 120/1 (I need Running Wolf) Running Wolf (I need Running Wolf)
    3
    Majestic Sun 5/2 (I need Majestic Sun) Majestic Sun (I need Majestic Sun)
    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

  9. #9
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Extract text to left of numer

    Quote Originally Posted by popipipo View Post
    Please Login or Register  to view this content.
    Does this work?
    No. the number still remains

  10. #10
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Extract text to left of numer

    Quote Originally Posted by AlKey View Post
    Maybe this

    =SUBSTITUTE(A1,MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&1234567890)),FIND("(",A1)-MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&1234567890))),"")

    Row\Col
    A
    B
    1
    Lord Brantwood 3/1 (I need Lord Brantwood) Lord Brantwood (I need Lord Brantwood)
    2
    Running Wolf 120/1 (I need Running Wolf) Running Wolf (I need Running Wolf)
    3
    Majestic Sun 5/2 (I need Majestic Sun) Majestic Sun (I need Majestic Sun)
    That gives an error #VALUE!

  11. #11
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Extract text to left of numer

    Quote Originally Posted by FDibbins View Post
    Hopefully someone else will come up with something more eligant, but this brute-force effort works without a helper...

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    It works - but is too long to be entered as VBA code as part of a macro

  12. #12
    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 text to left of numer

    Quote Originally Posted by cmb80 View Post
    That gives an error #VALUE!
    I dont' see any errors there.

    Please see attached file.
    Attached Files Attached Files

  13. #13
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Extract text to left of numer

    Quote Originally Posted by cmb80 View Post
    It works - but is too long to be entered as VBA code as part of a macro
    Perhaps that is a bit of info you should have made clear at the start?

  14. #14
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Extract text to left of numer

    Quote Originally Posted by cmb80 View Post
    That gives an error #VALUE!
    I also dont see any errors with AlKey's formula (beats the ^&* out of my monster, too)

+ 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. Extract text to left of number of bracket
    By cmb80 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-22-2014, 06:57 PM
  2. [SOLVED] Extract text to left of nth character
    By cmb80 in forum Excel General
    Replies: 3
    Last Post: 06-16-2014, 11:09 AM
  3. [SOLVED] Extract all text to the left of a hyphen ???
    By burdo77 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 03-06-2014, 03:54 AM
  4. Extract text left and right of character part 2
    By stuartm4h in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-01-2013, 07:12 AM
  5. [SOLVED] Extract text left and right of character
    By stuartm4h in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-12-2013, 07:32 AM

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