+ Reply to Thread
Results 1 to 12 of 12

Trying to extract text cells at the first instance of four consecutive numbers

  1. #1
    Registered User
    Join Date
    12-13-2012
    Location
    Portland, OR
    MS-Off Ver
    Excel 2003
    Posts
    61

    Trying to extract text cells at the first instance of four consecutive numbers

    example, if A1="abc def 2016 ghi jkl"

    B1 should="abc def "
    C2 should="2016 ghi jkl"

    It also needs to account for multiple instances of years in some strings and only extract the first instance. I would prefer not to use VBA if possible.

    I would use a search/replace technique but there are more than 70 different years, and that would be too tedious and time-consuming. Thanks!

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Trying to extract text cells at the first instance of four consecutive numbers

    You will need to upload an Excel Spreadsheet file with 20-30 rows of de-sensitized data that is representative of the mix you are working with.

    And please upload an Excel file and not a screen shot or pic. It saves having to retype data.


    If you are not familiar with how to do this:


    • click “Go Advanced” (next to Post Quick Reply – bottom right),
    • scroll down until you see “Manage Attachments”,
    • click “Browse”.
    • select your file(s)
    • click “Upload”
    • click “Close window”
    • click “Submit Reply”
    • The file name will appear at the bottom of your reply.
    Dave

  3. #3
    Registered User
    Join Date
    12-13-2012
    Location
    Portland, OR
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: Trying to extract text cells at the first instance of four consecutive numbers

    Here are a few more examples you can paste into excel if you want:

    column A:
    "abc def 2016 ghi jkl"
    "abc def 2015 ghi jkl 3033 mno"
    "abc def 2014 ghi jkl"
    "abc def 2012 ghi jkl 2125 mno"

    formula - column B should look like:
    "abc def "
    "abc def "
    "abc def "
    "abc def "

    formula - column C should like:
    "2016 ghi jkl"
    "2015 ghi jkl 3033 mno"
    "2014 ghi jkl"
    "2012 ghi jkl 2125 mno"

    Thanks for the help!

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Trying to extract text cells at the first instance of four consecutive numbers

    Try this in B1 and fill down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then this in C1 and fill down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-13-2012
    Location
    Portland, OR
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: Trying to extract text cells at the first instance of four consecutive numbers

    Nope, the text strings are random lengths. So change A1 to "abc def mno 2016 ghi jkl"

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Trying to extract text cells at the first instance of four consecutive numbers

    portokie,

    Here is what I got with the data supplied using those formulas ... which is what the anticipated output listed above is.



    A
    B
    C
    1
    abc def 2016 ghi jkl
    abc def
    2016 ghi jkl
    2
    abc def 2015 ghi jkl 3033 mno
    abc def
    2015 ghi jkl 3033 mno
    3
    abc def 2014 ghi jkl
    abc def
    2014 ghi jkl
    4
    abc def 2012 ghi jkl 2125 mno
    abc def
    2012 ghi jkl 2125 mno


    Would you give us a more comprehensive list of examples?
    Last edited by FlameRetired; 07-15-2016 at 05:43 PM.

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Trying to extract text cells at the first instance of four consecutive numbers

    Try this in B1 instead
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The formula in C1 will remain the same.

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Trying to extract text cells at the first instance of four consecutive numbers

    Try this...

    Data Range
    A
    B
    C
    1
    2
    abc def 2016 ghi jkl
    abc def
    2016 ghi jkl
    3
    abc def 2015 ghi jkl 3033 mno
    abc def
    2015 ghi jkl 3033 mno
    4
    abc def 2014 ghi jkl
    abc def
    2014 ghi jkl
    5
    abc def 2012 ghi jkl 2125 mno
    abc def
    2012 ghi jkl 2125 mno
    6


    This formula entered in B2:

    =LEFT(A2,MIN(FIND({1,2,3,4,5,6,7,8,9,0},A2&1234567890))-2)

    This formula entered in C2:

    =MID(A2,LEN(B2)+2,50)

    Select B2:C2 and copy down as needed.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Trying to extract text cells at the first instance of four consecutive numbers

    Tony,

    It appears OP wants to retain the trailing space in column B.

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Trying to extract text cells at the first instance of four consecutive numbers

    In that case replace -2 with -1.

  11. #11
    Registered User
    Join Date
    12-13-2012
    Location
    Portland, OR
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: Trying to extract text cells at the first instance of four consecutive numbers

    Sorry, I didn't realize it would be this complicated, so I figured out a workaround. Thanks again for the help!

  12. #12
    Registered User
    Join Date
    12-13-2012
    Location
    Portland, OR
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: Trying to extract text cells at the first instance of four consecutive numbers

    Hey I tried the formula and it worked! Great job! Thanks again!

+ 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] Extract all text from right until first instance of symbol
    By Daedra in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-19-2015, 06:28 AM
  2. Indicate the Instance of Consecutive Zeros in a Row
    By IbeforeV in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-04-2015, 04:27 PM
  3. [SOLVED] Extract numbers before first instance of text
    By pauldaddyadams in forum Excel General
    Replies: 5
    Last Post: 08-12-2014, 07:34 AM
  4. How to fill a column of cells with consecutive numbers ?
    By M-Ray in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2013, 09:59 AM
  5. Extract certain numbers from a column of text cells
    By yangliu2 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-05-2012, 10:19 PM
  6. Replies: 9
    Last Post: 10-21-2011, 01:55 PM
  7. How to Extract Text Before Second Instance of a Symbol
    By lionsdeal in forum Excel General
    Replies: 2
    Last Post: 08-04-2009, 02:28 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