+ Reply to Thread
Results 1 to 25 of 25

Excel 2007 : How to copy specific information from a cell with a lot of text to a separate cell.

  1. #1
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Smile How to copy specific information from a cell with a lot of text to a separate cell.

    Hi all,

    my problem is this:

    1'st I'm an Excel noob, haven't really used any advanced features.

    2'nd I need to copy specific information from a cell that has a lot of other text that's not needed in it.

    3'rd This has to be done several thousand times.

    f.ex. I've got a thousands of cells with: "Product name, compatability, product number, product dimensions, product specifications". How do I copy "compatability" on all these to a separate cell for each of the "compatability" automatically? I guess I'll have to use a macro, but does anybody know how I should code this?

    Would greatly appreciate any help.

    Best regards
    Thomas.
    Last edited by vikingim; 01-18-2012 at 02:54 AM.

  2. #2
    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,434

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    I guess I'll have to use a macro
    Not necessarily. Please post a sample with some typical examples and indicate what you need to extract and what "rules", if any, apply.


    Regards, TMS
    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


  3. #3
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    Hi TMS,

    thank you for your fast response.


    Here's a typical example of the content in one cell: produkt 226390 Barracuda Karizzma - 7,5x17" 4x108 - ET25 (73,1) - Mattsortpol. med valgfri kantfarge

    What I need to extract here is 4x108 and get it in a separate cell and automation of the whole process on all rows.

    I hope I've explained it good enough. hehe.

    Thomas.

  4. #4
    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,434

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    and what "rules", if any, apply
    So, not quite. How would someone, other than yourself, determine where the data you want to extract starts and ends? It doesn't really matter if the data is extracted with a formula or VBA ... it is still essential to know those details, that is, the "rules". I'm not familiar with the Norwegian language so the words don't tell me anything.

    Regards, TMS
    Last edited by TMS; 01-12-2012 at 10:36 AM.

  5. #5
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    The only "rule" I can think of, is that I know the data to be extracted is in this case "4x108".
    I'm probably as familiar with what excel can or can not do as you are with the Norwegian language, so please don't shoot me for being ignorant. lol.

    Thomas.

  6. #6
    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,434

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    I'm not shooting you for your ignorance of Excel. I'm just explaining that I, and others, need to go within the string to extract the data. You know why you're looking for 4x108. Why? Is there always a double quote and a space before it? Is there always a space hyphen space after it?

    If it is, this works (at least, for this specific example):

    =MID(A2,FIND(""" ",A2)+2,FIND(" - ",A2,FIND(""" ",A2))-FIND(""" ",A2)-1)

    If you were to tell me to come visit you, but didn't tell me your address ... country, city, road, house number ... I wouldn't know how to get there. I need some guidance.


    Regards, TMS

  7. #7
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    The reason I know I'm looking for 4x108 isn't in the string as far as I see it, other than that I know it's 4x108 I'm looking for.
    Isn't it possible to do a search for 4x108 and copy it to the cell next to the row it's extracted from?
    I'm sorry if my explanation and understanding of it is bad.

    Thomas.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    If your "compatibility string" was consistent in some manner, this would be easier. Perhaps you have a set list of all the possible compatibility strings, and its only 5-10 options? If so, you can list those in a column for reference to help. So over in column Z put your list:

    4x108
    5x109
    4x200
    2x75



    Then for the string in A2, put this formula in B2:

    =LOOKUP(2, 1/(--(ISNUMBER(SEARCH($Z$1:$Z$4, A2)))), $Z$1:$Z$4)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  9. #9
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    Hi JBeaucaire,

    Your suggestion looks reasonable to me.
    I've tried doing as you said, but I get an error when trying to save the formula in the cell.
    The error is "error in the formula" or something similar to that.
    I have a Norwegian version of Excel so I had to translate it. :P
    I've also tried translating the formula to Norwegian, but there's still the same error.

    Thanks for your help, I greatly appreciate it.

    Thomas.
    Last edited by vikingim; 01-16-2012 at 04:51 AM.

  10. #10
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    Here's a screenshot from one of the sheets I need it on, I hope it clarifies things a bit.
    excel1.gif

    Thanks,
    Thomas.

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    Why screenshots? Click GO ADVANCED and use the paperclip icon to post up a copy of your workbook.

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    Based on the picture, the formula to get the string from C2 would be:

    =LOOKUP(2, 1/(--(ISNUMBER(SEARCH($H$2:$H$11, C2)))), $H$2:$H$11)

  13. #13
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    That's what I thought as well, but I've tried both Norwegian and english version of the commands, but still get the error message. I've double checked the norwegian equalents to the LOOKUP, ISNUMBER and SEARCH commands. I have no idea why it doesn't work. I guess it would have worked if I had the english version though. lol.

  14. #14
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    Quote Originally Posted by JBeaucaire View Post
    Why screenshots? Click GO ADVANCED and use the paperclip icon to post up a copy of your workbook.
    Here's the workbook.

    eksperimentark1.xlsx

  15. #15
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    No, there's nothing country specific about that formula other than the commas vs semicolons.

    I added a named range called CODES to this worksheet. (Ctrl-F3 to see it) This named range will expand itself as you add/delete items from the H column. Ths changed the formula to:

    =LOOKUP(2, 1/(--(ISNUMBER(SEARCH(Codes, C2)))), Codes)


    ....which I put into E2, works fine.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    Ahh, thanks a lot. Works perfectly. Thanks a million!
    Just another thing: I see line 4 has the data needed in d4 instead, is it possible to add the D column to the formula as well? I could of course just change that line, but would be great, if it's possible to do the search on both columns.

    Thanks,
    Thomas.

  17. #17
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    You can use IFERROR() to run a second formula if the first results in an error:

    =IFERROR(LOOKUP(2, 1/(--(ISNUMBER(SEARCH(Codes, $C4)))), Codes), LOOKUP(2, 1/(--(ISNUMBER(SEARCH(Codes, $D4)))), Codes))


    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  18. #18
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    Excellent help JB! That works great. However, solving one problem shows a new one. lol. Several of the values are similar, like 4x114 and 4x114.3. How do I make sure that the formula picks the right one? I tried adding a space at the end to 4x114 and it works in some cases, but when 4x114 is at the end of a cell, there's no space, so it's not found. Another thing, some of the cells have more than one value I'm looking for, is it best to split what you called "codes" in the excel file you edited and recreate the formula on several colums, and then point the formula to "codes1", "codes2 etc.?

    Lot's of questions from me, and I highly appreciate you taking the time to help a noob like me. Let me know if you need some help with Photoshop or designing something, I'll be happy to help you back.

    Thomas.

  19. #19
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    Put the codes in the order you want them to be checked in that table. You would want the shorter codes above the "longer" versions and it will always return the longest matching code it finds. Just assemble your column H codes, then sort the table ascending, that should do it.

  20. #20
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    That worked perfectly. Thanks again JB.

    In regards to the second part of my previous post: My boss told me that the rows with more than one of the codes needs to be inserted in a separate row below the existing one. (To allow for our webshop import script to work correctly) The optimal thing would be if all the data from the row is copied to the row below. Of course only for the rows that has more than one of the codes. Is this possible?

    Thomas.

  21. #21
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    Quote Originally Posted by vikingim View Post
    Is this possible?
    Everything is possible. This technique is formulaic and will give you one code from the list.

  22. #22
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    Hehe, yeah. The problem is how to do it. Do you know what tecnhnique I need to use to figure out this new challenge?

    Thomas.

  23. #23
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    This new little addon takes your project up to a new level of complexity. Formulas cannot "insert rows", obviously, they can only display a value. So, this would require a complete specialized VBA approach.

  24. #24
    Registered User
    Join Date
    01-12-2012
    Location
    Sandefjord, Norway
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    That was what I was afraid of. :P Maybe it's just easier to edit the rows with more than one option manually. Hehe.
    Thank you for all your help JB, I really appreciate it. And as I said, if you need some Photoshop or design help, just give me a shout.

    Thomas.

  25. #25
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to copy specific information from a cell with a lot of text to a separate cel

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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