+ Reply to Thread
Results 1 to 11 of 11

formula extract text

  1. #1
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    487

    formula extract text

    Hello to all.
    In column C of the attached table there is text in each cell which is different between rows.
    I should extract from these cells the "NUMBER" which is after the word:
    ART./ART/Art./COD./COD./cod
    until you get to the first letter following this number.
    This number is not always the same but can be from 3 digits up to 12/13 digits.
    I have highlighted some in red.
    The number drawn must be placed in column D.
    I hope I have explained.
    Thanks
    john
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: formula extract text

    Try this in D2, copied down. It fails on a few that don't follow the typical pattern - if enough follow another pattern, you can add that extraction formula with an IFERROR or other conditional

    =IFERROR(LEFT(TRIM(MID(C2,FIND(".",C2)+1,LEN(C2))),FIND(" ",TRIM(MID(C2,FIND(".",C2)+1,LEN(C2))))-1),TRIM(MID(C2,FIND(".",C2)+1,LEN(C2))))
    Last edited by Bernie Deitrick; 11-09-2020 at 03:04 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    487

    Re: formula extract text

    Hi bernie,
    your formula works fine, for cells that don't correct I will do it by hand.
    A greeting and thanks again.
    john

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: formula extract text

    Formula for D2 =LEFT(TRIM(RIGHT(C2,LEN(C2)-IF(ISERROR(SEARCH("art.",C2)),SEARCH("cod.",C2),SEARCH("art.",C2))-3)),MIN(IF(ISERROR(MID(SUBSTITUTE(SUBSTITUTE(E2," ",1),".",1),ROW(INDIRECT("A1:A"&LEN(E2))),1)*1),ROW(INDIRECT("A1:A"&LEN(E2)))-1,LEN(E2))
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  5. #5
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    487

    Re: formula extract text

    Hi mehmetcik,
    your formula error #RIF!

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: formula extract text

    Apologies.

    Try:

    Formula for D2

    =LEFT(TRIM(RIGHT(C2,LEN(C2)-IF(ISERROR(SEARCH("art.",C2)),SEARCH("cod.",C2),SEARCH("art.",C2))-3)),MIN(IF(ISERROR(MID(SUBSTITUTE(SUBSTITUTE(TRIM(RIGHT(C2,LEN(C2)-IF(ISERROR(SEARCH("art.",C2)),SEARCH("cod.",C2),SEARCH("art.",C2))-3))," ",1),".",1),ROW(INDIRECT("A1:A"&LEN(TRIM(RIGHT(C2,LEN(C2)-IF(ISERROR(SEARCH("art.",C2)),SEARCH("cod.",C2),SEARCH("art.",C2))-3))))),1)*1),ROW(INDIRECT("A1:A"&LEN(TRIM(RIGHT(C2,LEN(C2)-IF(ISERROR(SEARCH("art.",C2)),SEARCH("cod.",C2),SEARCH("art.",C2))-3)))))-1,LEN(TRIM(RIGHT(C2,LEN(C2)-IF(ISERROR(SEARCH("art.",C2)),SEARCH("cod.",C2),SEARCH("art.",C2))))))))

  7. #7
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    487

    Re: formula extract text

    Hi mehmetcik,
    i your formula many words remain
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: formula extract text

    You need to array-enter the formula, using Ctrl-Shift-Enter instead of just enter.

  9. #9
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: formula extract text

    This is the sort of text parsing which simply doesn't make sense without regular expressions.

    If you're running under Windows, you can use VBScript regular expressions in VBA. I'm attaching a workbook including the VBA code and formulas to parse most of your numbers, which are much more complex than you describe.

    The regex user-defined function it uses is meant to provide the same results as LibreOffice Calc's function of the same name (in English).
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    487

    Re: formula extract text

    Hi bernie dietrich your formala CTRL+SHIFT+ENTER not work, always many words remain

  11. #11
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    487

    Re: formula extract text

    Hi hrlngrv,
    your macro solution works too, thanks.
    john

+ 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. Formula to extract text
    By nobodyukno in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-14-2014, 08:48 AM
  2. [SOLVED] Extract text from a string of text (amend formula to include new criteria)
    By robertguy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-10-2013, 04:53 PM
  3. [SOLVED] Help with a formula to extract text
    By SEMMatt in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-23-2012, 11:10 AM
  4. [SOLVED] how to extract text from a formula
    By wb in forum Excel General
    Replies: 0
    Last Post: 09-19-2005, 03:05 PM
  5. Extract formula from Text box
    By CLR in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 02-08-2005, 11:06 AM
  6. Can I extract text as a value from a formula?
    By Amy O in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-07-2005, 09:06 PM
  7. Can I extract text as a value from a formula?
    By Amy O in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-07-2005, 07:06 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