+ Reply to Thread
Results 1 to 12 of 12

Separating text in one cell into individual cells

  1. #1
    Registered User
    Join Date
    09-24-2008
    Location
    UK
    Posts
    75

    Separating text in one cell into individual cells

    Hello, I have a spreadsheet which needs formatting I was wondering if anyone would be able to help with creating a macro to do so. The problem with raw report is that in cell A47 there are five columns worth of data in that one cell, then in B48 there are another two, in b49 and b50 one respectively. I manually format it by first joining the separate cells using

    Please Login or Register  to view this content.
    Then convert text to columns. There are 4 tables of data in the Raw report sheet, D – HB / CTB and C – HB / CTB which I join to create into 1 table, but I index each table D – HB and D – CTB ect so that I can use this to filter the table. The raw report always comes out in this format but can vary in length, i.e the amount of records it produces, I was hoping to save some time formatting this as I need to do this on a regular basis.


    I’ve attached the file to show how the raw report is received and how it needs to end up. I have no knowledge of how to write VBA.

    I hope this makes sense, thanks in advance.

    If this is not possible or its not the done thing to request a macro from scratch please let me know and I will delete.
    Last edited by Hblbs; 01-22-2009 at 10:44 AM.

  2. #2
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Definitely possible

    It can definitely be done, and you're not asking too much.
    Heck if I have time today, and no one else has got around to it, I'll take a crack at it just for practice (I still have a lot to learn about this as well!). The cells all have exactly the same number of characters, so it could even be done with formulas.

    mew!

    EDIT:
    One question, where are the D, HB, CHB, etc. coming from on the second page?
    Last edited by mewingkitty; 01-09-2009 at 12:31 PM.
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

  3. #3
    Registered User
    Join Date
    09-24-2008
    Location
    UK
    Posts
    75
    Quote Originally Posted by mewingkitty View Post
    It can definitely be done, and you're not asking too much.
    Heck if I have time today, and no one else has got around to it, I'll take a crack at it just for practice (I still have a lot to learn about this as well!). The cells all have exactly the same number of characters, so it could even be done with formulas.

    mew!

    EDIT:
    One question, where are the D, HB, CHB, etc. coming from on the second page?
    Hi Mew, I add these in myself. Once all the data is separated in each cell and 1 row. At the begining of the table just after Breakdown there is the D records (HB) - cell A36, at the end of each table there is a Total (Total : 203) in cell A860 and 2 cells below that another table begins with the same column titles. Its used to index the data so I know which table these came from. Another thing is it always starts D - HB, the D (CTB), then C (HB), then C (CTB). Hope this helps.

  4. #4
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848
    Insert a sheet called "Transferred" into your workbook. Switch back to your raw data sheet.

    Run the following macro:
    Please Login or Register  to view this content.
    I didn't include any of the headings or the coloring or the info above the re-organized data.

  5. #5
    Registered User
    Join Date
    09-24-2008
    Location
    UK
    Posts
    75
    Hi, thanks for the code, it works up to a point. For some reason it does not separate text to columns, the data is all in one cell, a message box appears after the Macro is run "Microsoft Visual Basic . X . 400". Also it does not include the other 3 cells directly below which need to be aligned to the same row and if possible the headings too, although none of the colouring is needed.

    Thank you for taking the time to create this though as it still save me vast amounts of time as I do this a number of times during the week. Appreciate any/all other input in this. Thanks
    Last edited by Hblbs; 01-11-2009 at 03:49 PM. Reason: deleted spurious quote

  6. #6
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    eep

    I wrote one that had some kinks in it, but never finished it off because I saw someone else post here. I'll send it your way tomorrow if you still don't have an answer by then.

    mew.

    Eh
    re-wrote one, it's pretty... crude.

    Works, mostly, not sure what's happening with the format of the dates half way through though. So yeah, save a copy of the original. :P

    mew
    Attached Files Attached Files
    Last edited by mewingkitty; 01-13-2009 at 12:09 AM.

  7. #7
    Registered User
    Join Date
    09-24-2008
    Location
    UK
    Posts
    75
    Hi mewingkitty,

    This mostly does what is required, but in the formatted report it does not pick up some data, mainly in the exclude from stats column, but mostly it misses out indexing the data according to D or C and HB or CTB.

    Thanks for yours and mdbct's contribution, your macro includes most of the data and mdbct's includes the indexing aspect required. If anyone knows how to combine aspects of the two it would be appreciated.

    Thanks in advance.

  8. #8
    Registered User
    Join Date
    09-24-2008
    Location
    UK
    Posts
    75
    Bump to see if anyone can help as I'm hopeless at VBA.

    What I'm looking is a combination of the 2 codes provided so far, the code by Mewingkitty separates all the data I need and the code by mdbct indexes the data the way I need it.

    If anyone can help, it would be appreciated. Thanks

  9. #9
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848
    Here is a combined version
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    09-24-2008
    Location
    UK
    Posts
    75
    Thanks mdbct, this works and picks up all the data.

    The only thing is that the date format for D:G does not seem to work on CTB records. When I try to insert a formula for cells E and F it does not seem to work for CTB records. Here is the formula :-

    Please Login or Register  to view this content.
    The error message in the cell is #VALUE!.

    Essentially I'm trying to join your code to my own whic does not seem to be working, I can post it up if you'd like. Otherwise any help on this is appreciated.
    Last edited by Hblbs; 01-22-2009 at 06:25 AM.

  11. #11
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848
    the formatting issue was because I forgot to specify the sheet whose columns were to be formatted.

    The CTB issue is due to there being a space in front of the time, so Excel is interpreting it as a text value instead of a Date Time value.

    Try this version.
    Please Login or Register  to view this content.

    Addendum: I forgot to mention that I added your formula to the L column
    Last edited by mdbct; 01-22-2009 at 10:12 AM. Reason: Addendum

  12. #12
    Registered User
    Join Date
    09-24-2008
    Location
    UK
    Posts
    75
    Fantastic, works perfectly.

    Thank you very much for all your help, also to Mewingkitty for contributing.

    This coding will save me a couple of hours a week, as opposed to manually formatting this.

+ 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