+ Reply to Thread
Results 1 to 21 of 21

[SOLVED] Extracting Data Located in Single Cell

  1. #1
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    [SOLVED] Extracting Data Located in Single Cell

    Hi All,

    I think my problem can only be done using VBA and that is why i am posting here. I hope someone can help.

    Here is my challenge.

    I am trying to extract individual pieces of information that exist in a singe cell, and paste them independently. Then copy one piece of information and paste them repeatedly to match the extracted data.

    Please see the attached file of what i am trying to accomplish. It will probably makes more sense.

    If anyone can kindly show me a quick way of doing this i would really appreciate your help. I have over 300 lines of these data i need to organise.

    By the way. I am not really that good with VBA so please bare with me.

    Thanks in Advance.
    Attached Files Attached Files
    Last edited by crazysniper; 06-01-2011 at 11:06 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
    48,290

    Re: Extracting Data Located in Single Cell

    No attached 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


  3. #3
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Re: Extracting Data Located in Single Cell

    apologise.. i have just realised that.
    It should be there now.

    Thanks for the prompt reply.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Extracting Data Located in Single Cell

    Hi,

    Try this, it will put the extracted data on a second sheet rather than below, is this what you want?

    Please Login or Register  to view this content.
    Last edited by Kyle123; 06-01-2011 at 05:29 AM.

  5. #5
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Re: Extracting Data Located in Single Cell

    Hi Kyle123,

    You nailed it. Except they are being duplicated.

    Would you mind applying the same principle to this second file attached. For Sheet 3. I am trying to analyse your code, hoping I can replicate this in the future.

    Thank you ever so much.
    Attached Files Attached Files

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Extracting Data Located in Single Cell

    Hi,

    They are duplicated as you have your example below, it is returning these names also on the second sheet. I'd assumed that you wouldn't have the example of how you'd like the data to look on the actual document. Let me know if I got this wrong and I'll have a look

    I'll have a look at your other workbook

  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
    48,290

    Re: Extracting Data Located in Single Cell

    A slightly different approach:

    Please Login or Register  to view this content.

    Regards

  8. #8
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Re: Extracting Data Located in Single Cell

    Hi Kyle,

    If possible I only want the organised data to appear on the second sheet.

    I so envy people like you.. i wish i can be good with VBA too

    Thanks once again.


    Quote Originally Posted by Kyle123 View Post
    Hi,

    They are duplicated as you have your example below, it is returning these names also on the second sheet. I'd assumed that you wouldn't have the example of how you'd like the data to look on the actual document. Let me know if I got this wrong and I'll have a look

    I'll have a look at your other workbook

  9. #9
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Re: Extracting Data Located in Single Cell

    @ TMShucks

    Your code works too...

    Thank you as well...

    This is soo cool. A task that normally takes god knows how many hours, can be done in split seconds.. waaaa.. I need to learn VBA.

    You guys have any tips how can one learn this language?


    Quote Originally Posted by TMShucks View Post
    A slightly different approach

    Regards

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Extracting Data Located in Single Cell

    Hi

    Try this for your second problem NB in your example, there is an additional return after the last entry in the "multiple" cells. If this is the same on all lines then the below will work, note the UBound(varBatchNo) - 1 the minus one is to remove the extra return.

    You'll need to put an additional sheet in your workbook for the below:

    Please Login or Register  to view this content.
    Let me know if this works for you

  11. #11
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Extracting Data Located in Single Cell

    No probs


    If possible I only want the organised data to appear on the second sheet.
    Just to clarify:

    Only the organised data will appear on the second sheet if you remove the desired output from below the data.

    Are you saying that on your actual data there will be text below the list of names/departments?

  12. #12
    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
    48,290

    Re: Extracting Data Located in Single Cell

    @crazysniper: you're welcome. Thanks for the rep.

    I think my code would require a little more tweaking and possibly a rethink so I will leave you working with Kyle123 as his version is up and running.

    In terms of learning VBA, the question has been asked before, as you might imagine. See the following thread for some ideas.

    http://www.excelforum.com/the-water-...for-excel.html

    The forum is a good source of inspiration and you'll find, as in this case, there can be several ways of approaching a problem.


    Regards

  13. #13
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Re: Extracting Data Located in Single Cell

    Hi Again Kyle,

    I assume the second code is for the Sheet3 of the v2 file? The code runs but unfortunately no output to Sheet4.

    Also just to clarify, my data will be in the same format as in Sheet3. There are more than 300 Rows of these badly in putted data.. And there is no text below the tables that does not correspond to the data its representing, if this is what you mean.

    Thanks again for the help. I really appreciate it.


    Quote Originally Posted by Kyle123 View Post
    No probs

    Just to clarify:

    Only the organised data will appear on the second sheet if you remove the desired output from below the data.

    Are you saying that on your actual data there will be text below the list of names/departments?

  14. #14
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Extracting Data Located in Single Cell

    Try this,

    I'm guessing it's to do with the sheet naming. Let me know if it works for you.

    Also just to clarify, my data will be in the same format as in Sheet3. There are more than 300 Rows of these badly in putted data.. And there is no text below the tables that does not correspond to the data its representing, if this is what you mean.
    Great, that means the code I posted first will work
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Re: Extracting Data Located in Single Cell

    That is perfect Kyle. You're a life saver.

    So, I just paste this Code to the Visual Basic Editor of the Workbook, tweak the sheet names. Then all 300 Rows will be converted?

    This is amazing.. Thank you ever so much.


    Quote Originally Posted by Kyle123 View Post
    Try this,

    I'm guessing it's to do with the sheet naming. Let me know if it works for you.

    Great, that means the code I posted first will work

  16. #16
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Extracting Data Located in Single Cell

    Yep, fingers crossed!!

    For the first problem, you may need to tweak the columns in the code if the job title isn't in column E etc.

  17. #17
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Re: Extracting Data Located in Single Cell

    Superb.

    Will test this now and see how it goes.

    Thanks once again.

    Quote Originally Posted by Kyle123 View Post
    Yep, fingers crossed!!

    For the first problem, you may need to tweak the columns in the code if the job title isn't in column E etc.

  18. #18
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Re: Extracting Data Located in Single Cell

    Hi Kyle.

    Unfortunately, it does not work. Probably to do with naming again.

    In VBA Window a sheet looks like this Sheet1(Sheet1) by default. But if Sheet1 is labelled, for example Customer. It will become like this Sheet(Customer)

    In your code, how did you define the sheet names?

    Thanks again.


    Quote Originally Posted by crazysniper View Post
    Superb.

    Will test this now and see how it goes.

    Thanks once again.


    Quote Originally Posted by crazysniper View Post
    Superb.

    Will test this now and see how it goes.

    Thanks once again.

  19. #19
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Extracting Data Located in Single Cell

    Generally in VBA sheets should be Sheetx(Whateveryoucalledit) if using sheetx, they don't need defining. The best thing to do is every time in my code you see sheetx, replace it with sheets("Customer") or whatever sheet you need.

    Does this make sense?

  20. #20
    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
    48,290

    Re: Extracting Data Located in Single Cell

    Sheets have a code name and sheet/tab name. You can change either or both. The sheet/tab name is the one that's visible.

    Some examples in the Immediate window:

    Please Login or Register  to view this content.

    Regards

  21. #21
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Re: Extracting Data Located in Single Cell

    OK I figured it out. Silly me. I had to reverse the name. i.e. the Sheetx from the bottom of the code should be the one on the top.So that resolves it.

    Thank you ever so much Kyle.

    And also thanks as well to TMShucks


    Quote Originally Posted by Kyle123 View Post
    Generally in VBA sheets should be Sheetx(Whateveryoucalledit) if using sheetx, they don't need defining. The best thing to do is every time in my code you see sheetx, replace it with sheets("Customer") or whatever sheet you need.
    Does this make sense?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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