+ Reply to Thread
Results 1 to 11 of 11

Extracting Text and Numbers from a cell with varying lengths and no spaces

  1. #1
    Registered User
    Join Date
    10-25-2022
    Location
    portland
    MS-Off Ver
    Office 365
    Posts
    3

    Extracting Text and Numbers from a cell with varying lengths and no spaces

    Hello,

    I have a set of cells from Column A from which I have to extract information for a different cell.
    For instance, From Column A
    AUS177-4M
    Canada551-3W
    MEX316-3W
    US160-3Mo
    ARG265-2W
    MEX363-5Mo
    US351-4W
    GER195-6Mo

    1.I have to extract the Country, which varies between cells.
    2. I have to extract the # following the country and before the "-"
    3. As well as the Information afterward.

    All of the tutorials I have watched require things like spaces to extract any idea on how to do it?

  2. #2
    Registered User
    Join Date
    10-25-2022
    Location
    portland
    MS-Off Ver
    Office 365
    Posts
    3

    Extracting Text and Numbers from a cell with varying lengths and no spaces

    Hello

    From Column A I have text that looks like the following

    GER442-10M
    Japan17-8W
    Canada559-11Mo
    ARG389-11Mo
    Canada121-12M
    GER489-13W
    GER88-11M
    MEX455-4W
    AUS491-14Mo
    MEX193-11W

    1. I have to extract things such as Country from the left.
    2. The numbers immediately following the Country and before the "-"
    3. Text after the "-"
    4 Letters after the last part.

    Sorry if this seems easy I'm relatively new to excel. Any ideas?
    Attached Files Attached Files
    Last edited by fortnitergamer22; 10-25-2022 at 08:14 PM.

  3. #3
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Extracting Text and Numbers from a cell with varying lengths and no spaces

    show expected result or will be better if you attach example excel file with Before and After data. Read big yellow banner at the top of this site

  4. #4
    Registered User
    Join Date
    10-25-2022
    Location
    portland
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Extracting Text and Numbers from a cell with varying lengths and no spaces

    Hi I have done it Sorry for multiple posts. The first time it crashed and I didn't think it posted

  5. #5
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Extracting Text and Numbers from a cell with varying lengths and no spaces

    sure,, next time attach excel file as described at the top yellow banner
    and show your own solution for others here
    have a nice day

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,685

    Re: Extracting Text and Numbers from a cell with varying lengths and no spaces

    Assuming the data starts in cell A1, use the following formulae in the cells stated:

    C1: =LEFT(A1,FIND("-",A1)-4)

    D1: =MID(A1,LEN(C1)+1,3)

    E1: =RIGHT(A1,LEN(A1)-FIND("-",A1))

    then copy down as required. Note that the first two assume that the numbers are 3 digits, as in all your examples.

    Hope this helps.

    Pete

  7. #7
    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,301

    Re: Extracting Text and Numbers from a cell with varying lengths and no spaces

    @Pete, et al. Just be aware this thread has been duplicated and there is activity on the other thread (with a sample file).
    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


  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,685

    Re: Extracting Text and Numbers from a cell with varying lengths and no spaces

    Thanks for the info, Trevor.

    Maybe a Mod will merge the duplicates into one thread (it used to happen quite often).

    Pete

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,685

    Re: Extracting Text and Numbers from a cell with varying lengths and no spaces

    Actually, looking at the posting times of both threads, it is the other one which is a duplicate of this one, so the other responses should be merged into this one and then the other thread could be deleted. Although there is activity on the other thread, no solution has been suggested yet.

    Pete

  10. #10
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,822

    Re: Extracting Text and Numbers from a cell with varying lengths and no spaces

    Maybe not the most efficient, but they should work:

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

    C2:
    =MID(A2,LEN(B2)+1,SEARCH("-",$A2)-LEN(B2)-1)

    D2:
    =TRIM(LEFT(RIGHT(A2,LEN(A2)-SEARCH("-",A2)),MIN(SEARCH({"A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";"P";"Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z"},RIGHT(A2,LEN(A2)-SEARCH("-",A2))&"ABCDEFGHIJKLMNOPQRSTUVWXYZ"))-1))

    E2:
    =LET(a,RIGHT(A2,LEN(A2)-SEARCH("-",A2)),RIGHT(a,LEN(a)-MIN(IFERROR(SEARCH({"A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";"P";"Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z"},a),""))+1))

  11. #11
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Extracting Text and Numbers from a cell with varying lengths and no spaces

    EmployeeCode Location EmpID PlantID PayPeriod
    AUS177-4M AUS
    177
    4
    M
    Canada551-3W Canada
    551
    3
    W
    MEX316-3W MEX
    316
    3
    W
    US160-3Mo US
    160
    3
    Mo


    Please Login or Register  to view this content.

+ 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 last numbers in a column of varying lengths/formats
    By Stuepef in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-25-2018, 03:39 PM
  2. Extract last numbers in a column of varying lengths/formats
    By Stuepef in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-25-2018, 12:15 PM
  3. [SOLVED] Extract last numbers in a column of varying lengths/formats
    By Stuepef in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-06-2018, 11:40 AM
  4. [SOLVED] Extract all numbers from cells with varying lengths
    By Stuepef in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-04-2018, 02:47 AM
  5. Extracting text/numbers form varying source data
    By Sybie in forum Excel General
    Replies: 4
    Last Post: 01-15-2013, 07:18 AM
  6. Replies: 3
    Last Post: 05-09-2012, 11:36 AM
  7. Parse Strings of Space-Separated Text of Varying Lengths
    By mlexcelhelpforum in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-09-2011, 07:49 AM

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