+ Reply to Thread
Results 1 to 10 of 10

Extracting text into multiple columns

Hybrid View

  1. #1
    Registered User
    Join Date
    08-13-2010
    Location
    Slough, UK
    MS-Off Ver
    Excel 2010
    Posts
    18

    Extracting text into multiple columns

    Hi everyone,

    This is my first post but I've already benefitted greatly from various posts on here, so many thanks to all you more seasoned forum users!

    I have a column that looks something like this:

    A:20 B:50 C:30 D:15
    A:52 E:19 L:6 P:20
    C:42 F:65 G:7 N:90
    etc., which constitutes a list of recipes for our products.

    I need 16 separate columns, A to P, which contain only numbers. So, for example, the first row would look like:
    A:20 B:50 C:30 D:15 | 20 | 50 | 30 | 15 | | | | | | | | | | | | |
    where | is a cell separator.

    Is there a way of automatically extracting these values? I realise it's in a horrible format, and up till now I've been doing it manually, but our latest spreadsheet needs 913 of these done, so it would be fantastic to have a nicer way of doing it.

    Thanks in advance for your help

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Extracting text into multiple columns

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

  3. #3
    Registered User
    Join Date
    08-13-2010
    Location
    Slough, UK
    MS-Off Ver
    Excel 2010
    Posts
    18

    Post Re: Extracting text into multiple columns

    teylyn, thanks for your quick help!

    I've attached a dummy spreadsheet to better illustrate my point.

    Our products are paints, and the recipe line lists first the base and pack size, and then all pigments required to be added. The base and pack size have been manually extracted, as shown. I've filled in red to give the result I want to achieve - I will then go on and use the values to calculate costs based on the different costs of different pigments.

    As you can see, the numbers may be 1, 2 or 3 digits, but never more than 3.

    Correction: Having manually scanned the spreadsheet, there are in fact some 4-digit values too. Also please note that "M" can be either a base or a pigment, which might further complicate the text searching :S
    Attached Files Attached Files
    Last edited by banana-pumpkin; 08-13-2010 at 05:48 AM. Reason: Omitted important information

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Extracting text into multiple columns

    Will the values ever be only one or two digits? Then this solution may work

    =IF(ISNUMBER(SEARCH(B$1&":",$A2)),MID($A2,FIND(B$1,$A2)+2,2)*1,"")

    see it applied in the attached file.

    If your numeric values can be from 1 to 3 or more digits, then we need to re-think.

    cheers,
    Attached Files Attached Files

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Extracting text into multiple columns

    What's with "5L" in your data sample, cell B2? How should that be treated? Include the "L"? Chop it off and leave just the number?

    Can you provide a data sample that lists all possible variations for column B and manually put in what the expected result would be in E to T?

    Otherwise, we're pretty much left to guessing, which does not benefit either you or the willing (unpaid) helpers here.

    cheers

  6. #6
    Registered User
    Join Date
    08-13-2010
    Location
    Slough, UK
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Extracting text into multiple columns

    Hi,

    I screwed up the Dummy sheet

    Without actually giving you the real sheet, which is strictly prohibited by my company, this is about the clearest I can do.
    B to X are the pigment columns.
    Pack size can be either 2.5L or 5L.
    Base can be L, M or E.
    I already have the Base and Pack size columns filled in, so it's only the pigment ones that I need help with.

    Cheers
    Attached Files Attached Files

  7. #7
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Extracting text into multiple columns

    How do you distinguish between

    M:5L to go into Pack Size in column D

    and

    M:20 to go into the column for the M value?

  8. #8
    Registered User
    Join Date
    08-13-2010
    Location
    Slough, UK
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Extracting text into multiple columns

    Manually it's easy, because the base and pack size is always the first information in the cell and the pigment information follows after. Also, all pack sizes are appended with "L" (i.e. litres), whereas pigment numbers are just numbers.

    So you could never get e.g. G:10 M:20 M:2.5L, it would always appear as M:2.5L G:10 M:20 in the recipe cell.

  9. #9
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Extracting text into multiple columns

    OK, see what you can do with the attached.

    the formula for column C, applied in row 9 is

    =LEFT(B9,1)

    for column D, applied in row 9 is

    =MID(B9,3,FIND(" ",B9)-2)

    for columns E to T

    =IF($C9=E$1,"",IF(ISERROR(FIND(E$1&":",$B9)),"",MID($B9,FIND(E$1,$B9)+2,FIND(" ",$B9&" ",FIND(E$1,$B9)+2)-(FIND(E$1,$B9)+2))*1))

    Will that work for you? See attached file, row 9ff.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    08-13-2010
    Location
    Slough, UK
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Extracting text into multiple columns

    That is absolutely amazing! You have saved me hours of tedium and taught me some new formulae as well! Thank you so much

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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